SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Site Related Forums
 Article Discussion
 count the number items in a table
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Phaswana
Starting Member

South Africa
1 Posts

Posted - 05/23/2013 :  17:47:22  Show Profile  Reply with Quote
i have table A and B such that A(1,2,3,4,5) and B(1,1,1,1,1,1,2,2,3,5,5,5,6,6). now I want to count the number of items in A that exists in B including the ones that don't exists in B then show them as table C such that C(1=6,2=2,3=1,4=0)

how can i do this?

PM Malatjie

James K
Flowing Fount of Yak Knowledge

3706 Posts

Posted - 05/23/2013 :  18:02:48  Show Profile  Reply with Quote
select
	a.col,
	count(b.col)
from
	a
	left join b on a.col = b.col
group by
	a.col;
Go to Top of Page

philipcarter99
Starting Member

USA
1 Posts

Posted - 06/11/2013 :  05:17:37  Show Profile  Reply with Quote
Hi ,i had the same query where i couldn't find exact code ..really loved it ..Thank u guys for posting this solution .

unspammed
Go to Top of Page
  Previous Topic Topic Next Topic  
 New 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.06 seconds. Powered By: Snitz Forums 2000