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
 SQL Server 2005 Forums
 SSIS and Import/Export (2005)
 struck on a query

Author  Topic 

abbikhan
Starting Member

26 Posts

Posted - 2011-04-26 : 15:07:08
SELECT DISTINCT t2.appID,t2.[name]
FROM (
SELECT DISTINCT AA1.pid
FROM tableAA1 AS AA1 INNER JOIN (SELECT MAX(ID) AS ID
FROM tableAA2
GROUP BY pID) AS SIp
ON AA1.ID=SIp.ID INNER JOIN stable AS St ON St.id=AA1.SID
WHERE St.id NOT IN (5,8,9) AND AA1.coluBy2 < @coluBy3
)AS A
INNER JOIN table1 As t1
ON t1.id=A.pid INNER JOIN table2 AS t2 ON t2.ID=t1.sID
INNER JOIN table3 AS t3 ON t2.ID=t3.stID
WHERE coluBy=@coluBy


i have same query for another part in which i have @coluBy3 with
different parameter value and also joins ( INNER JOIN table1 As t1
ON t1.id=A.pid INNER JOIN table2 AS t2 ON t2.ID=t1.sID
INNER JOIN table3 AS t3 ON t2.ID=t3.stI) with some more tables like table1 and table2 from them + table6

problem is :
how can i combine them in a single sp as some times user wan to have results form both parts or some time from one only

help me in it please

robvolk
Most Valuable Yak

15732 Posts

Posted - 2011-04-26 : 15:12:38
Please do not cross post:

http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=159939
Go to Top of Page
   

- Advertisement -