|
abbikhan
Starting Member
26 Posts |
Posted - 04/26/2011 : 15:10:36
|
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 |
Edited by - abbikhan on 04/26/2011 17:12:50
|
|