Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 Other Development Tools
 i need this query asap to be put into a stored pro

Author  Topic 

mahesh423
Starting Member

9 Posts

Posted - 2008-09-29 : 07:55:40
I want a sybase query to include in my stored procedure.plz help?
i created a temp table with four columns a1,a2,b1,b2.
i got to insert data into a1,a2 from a table with few conditions in where clause.
i got to insert data into b1,b2 from the same table with few other conditions in where clause ( few same conditions as first insert statement).
a2 and b2 are count func (aggregate functions)don't dont want to use two temp tables.
this all to be done in a stored procedure.
is there any possibility to do these operation?
is there any possibility to use same table with two aliases in one insert query? i find aggragate func as a barrier for that..
at the end i got to select all the four columns from temp table to be printed into a file..

so plz suggest something suitable

Mahesh Kumar

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-09-29 : 08:01:50
With the very little helpful information you have given,
let's try something like this
SELECT		t1.a1,
t1.a2,
t2.b1,
t2.b2
FROM (
SELECT Col1 AS a1,
COUNT(*) AS a2
FROM Table1
GROUP BY Col1
) AS t1
FULL JOIN (
SELECT Col1 AS b1,
COUNT(*) AS b2
FROM Table2
GROUP BY Col1
) AS t2 ON t2.b1 = t1.a1



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-09-29 : 08:04:53
Please note that the syntaxes used here are as per MS SQL Server and so it may not work well with sybase. For getting more accurate results relating to sybase, please post it in some sybase forums. This forum is for MS SQL Server.
Go to Top of Page

afrika
Master Smack Fu Yak Hacker

2706 Posts

Posted - 2008-09-29 : 08:10:11
I thought this was "YAK CORRAL" ?
Go to Top of Page

mahesh423
Starting Member

9 Posts

Posted - 2008-09-30 : 00:57:18

well what is missing ?
i mean what else you felt i wud have included in it..?
well let me try this...which u posted
i will ge back to you on this..
thanks in advance..

Mahesh Kumar
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-09-30 : 01:12:45
quote:
Originally posted by mahesh423


well what is missing ?
i mean what else you felt i wud have included in it..?
well let me try this...which u posted
i will ge back to you on this..
thanks in advance..

Mahesh Kumar


please refer below for instructions on how to post a question

http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx
Go to Top of Page

mahesh423
Starting Member

9 Posts

Posted - 2008-09-30 : 02:21:03
Hi
FULL JOIN doesnt work in sybase..
and the thing is both the queries are different from each other.
So i dont have any join condition to appy on it..
how can i put this two inner select queries together in an outer select query..?

Mahesh Kumar
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-09-30 : 02:44:24
quote:
Originally posted by mahesh423

Hi
FULL JOIN doesnt work in sybase..
and the thing is both the queries are different from each other.
So i dont have any join condition to appy on it..
how can i put this two inner select queries together in an outer select query..?

Mahesh Kumar


then post in some sybase forums for more help
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-09-30 : 03:46:37
First you wrote
quote:
Originally posted by mahesh423

So i dont have any join condition to appy on it..


and then you wrote
quote:
Originally posted by mahesh423

how can i put this two inner select queries together in an outer select query..?


If you don't have any JOIN condition, how do you think an OUTER JOIN would work?



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

mahesh423
Starting Member

9 Posts

Posted - 2008-09-30 : 09:08:57
Hi
for the solution provided to me, i tried that..but i didnt had any joins..so it didnt work out...
anyways i tried something else which is kinda hardcoded thing.
thanks for your help ...


Mahesh Kumar
Go to Top of Page
   

- Advertisement -