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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Select statement with count

Author  Topic 

Vack
Aged Yak Warrior

530 Posts

Posted - 2013-01-07 : 13:08:57
[code]
Table Name: imtagfil

item_no bin_no Lot_no
ABC 11 3B
ABC 11 3B
ABC 12 3B


I'm looking for a select statement that will return the number of records for each matching bin and lot number.

item_no bin_no lot_no count
ABC 11 3B 2
ABC 12 3B 1





[/code]

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2013-01-07 : 13:39:01
select
item_no,
bin_no,
lot_no,
count(*) as [count]
from imtagfil
group by
item_no,
bin_no,
lot_no


Too old to Rock'n'Roll too young to die.
Go to Top of Page
   

- Advertisement -