Please start any new threads on our new site at We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 execute query without joins
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Starting Member

2 Posts

Posted - 04/10/2013 :  15:03:43  Show Profile  Reply with Quote
Hi frds,

Do anyone know how to replace joins?

Suppose i have 2 tables, one is department and the other is employee.

deptno deptname
10 finance
20 support
30 sales
empid deptno
ABC 10
DEF 20
GHI 20

now i want number of employee in each department with department having 0 employee also like below but without any joins.

Deptno count
10 1
20 2
30 0

waiting for ans..

James K
Flowing Fount of Yak Knowledge

3873 Posts

Posted - 04/10/2013 :  15:09:07  Show Profile  Reply with Quote
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):
Go to Top of Page

Flowing Fount of Yak Knowledge

4614 Posts

Posted - 04/10/2013 :  15:54:10  Show Profile  Reply with Quote
Try searching for "correlated subquery" that is another way to avoid a join for some reason.
Go to Top of Page

Starting Member

2 Posts

Posted - 04/11/2013 :  00:14:09  Show Profile  Reply with Quote
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?
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000