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.
| Author |
Topic |
|
dhani
Posting Yak Master
132 Posts |
Posted - 2010-02-01 : 20:08:11
|
| Hello All,i am using 3 tables in my queryTable A, Table B, Table CA is the super table it has a column name --> objectid, which can find in both b & c sub tablesso i wrote query as belowselect con.objectid as CID,count(TableObjIns.LID) as LCountfrom TableContra as Con left join TableObj on TableObj.objectid = Con.objectid left join TableObjIns on TableObjIns.attr1538=con.attr1485 group by con.objectidorder by 2 descnow i have a little problem in my answer, one of team mate suggest me, i have to join Table A to Table B then Table A to Table c finally Table B to Table C,so i tried below way, but i didn't get my result, but she suggested me i need to write a join (either Table A to B or B to C) then join to other table so for that i tried below but i am getting errorscould you please tell me how to write a query (ex Table A, B ,C) Ato B in one query and (b to c) in one query then join together like...i tried below query (which results an error)select con.objectid as CID,count(TableObjIns.LID) as LCountfrom TableContra as Con left join TableObj on TableObj.objectid = Con.objectid left join TableObjIns on TableObjIns.attr1538=con.attr1485 left join TableObjas b on b.objectid = TableObjIns.objectid group by con.objectidorder by 2 descPlease Help Me sir |
|
|
bklr
Master Smack Fu Yak Hacker
1693 Posts |
Posted - 2010-02-01 : 23:13:53
|
try like thisselect con.objectid as CID, count(TableObjIns.LID) as LCountfrom TableContra as Con left join TableObj AS o on o.objectid = Con.objectid left join TableObjIns AS i on i.attr1538=con.attr1485 and i.objectid = Con.objectid group by con.objectidorder by 2 desc |
 |
|
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2010-02-01 : 23:15:47
|
| What is the error you get?Harsh Athalyehttp://www.letsgeek.net/ |
 |
|
|
|
|
|
|
|