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 |
|
Sarakumar
Posting Yak Master
108 Posts |
Posted - 2006-04-26 : 01:43:35
|
| hai, usually we can join two tables to get the expected result..select B.name from(select name,createddate from tbl1 group by createddate,name)BThe above is possible...But in the same above query can i use inner join with the same B table.say, select B.name from(select name,createddate from tbl1 group by createddate,name)Binner join B as Renametable on Renametable.name = 'Shyam' |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-04-26 : 01:51:58
|
| You can simply writeselect B.name from(select name,createddate from tbl1 group by createddate,name)Bwhere name = 'Shyam'orselect B.name from(select name,createddate from tbl1 where name = 'Shyam' group by createddate,name)BMadhivananFailing to plan is Planning to fail |
 |
|
|
Sarakumar
Posting Yak Master
108 Posts |
Posted - 2006-04-26 : 01:57:25
|
| In my requirement i want to treat this B as two different table and compare something...that's y i asked is it possible to use |
 |
|
|
chiragkhabaria
Master Smack Fu Yak Hacker
1907 Posts |
Posted - 2006-04-26 : 02:03:28
|
| I dont think by doing this will get the expected result, since it will cross join between both the tables.. Somthing like this.. select B.name from(select Pk,name,createddate from tbl1 group by createddate,name)Binner joinB as Renametableon Renametable.[Pk]= b.[Pk] and Renametable.name = 'Shyam'If Debugging is the process of removing Bugs then i Guess programming should be process of Adding them. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-04-26 : 02:05:19
|
| You can inner join with other table as select B.name from(select name,createddate from tbl1 group by createddate,name)Binner join OtherTable O on B.name=O.nameOtherwise you need to use the same query twiceselect B.name from(select name,createddate from tbl1 group by createddate,name)Binner join(select name,createddate from tbl1 group by createddate,name)Con B.name=C.nameor move the result to temp table and do query based on itInsert into #tempselect name,createddate from tbl1 group by createddate,nameselect B.name from #temp B inner join #temp Con B.name=C.name where B.name='Somename'Otherwise post your exact requirementMadhivananFailing to plan is Planning to fail |
 |
|
|
Sarakumar
Posting Yak Master
108 Posts |
Posted - 2006-04-26 : 02:16:44
|
| Thanks a lot |
 |
|
|
|
|
|
|
|