Please start any new threads on our new site at http://forums.sqlteam.com. 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
 
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
 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

3873 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  
 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.05 seconds. Powered By: Snitz Forums 2000