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 |
bhavesh205
Starting Member
2 Posts |
Posted - 2013-04-10 : 15:03:43
|
Hi frds,Do anyone know how to replace joins? Suppose i have 2 tables, one is department and the other is employee.Dept______________________deptno deptname------------------------10 finance20 support30 sales______________________employee___________________empid deptno---------------------ABC 10DEF 20GHI 20now i want number of employee in each department with department having 0 employee also like below but without any joins.Deptno count-----------------------10 120 230 0waiting for ans.. |
|
James K
Master Smack Fu Yak Hacker
3873 Posts |
Posted - 2013-04-10 : 15:09:07
|
The best way would be to do joins, so I am not clear why you want to avoid joins. Are you running into any problems? If you must avoid joins, you could use outer apply (but I think of it being sort of like a join): http://technet.microsoft.com/en-us/library/ms175156(v=SQL.105).aspx |
|
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2013-04-10 : 15:54:10
|
Try searching for "correlated subquery" that is another way to avoid a join for some reason. |
|
|
bhavesh205
Starting Member
2 Posts |
Posted - 2013-04-11 : 00:14:09
|
I do have knowledge and i have successfully executed it without any problem but i just want to know is it be possible to execute join without join? |
|
|
|
|
|