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 |
dmcdonnell
Starting Member
2 Posts |
Posted - 2013-10-21 : 13:47:02
|
So i have a database where I need to count the occurances of part numbers in warehousesso i may havePartNo___________Warehouse906______________T1011408______________T1080906______________T1080906______________T1011and i need returnedPartNo___________Warehouse___________Occurence906______________T1011_______________2408______________T1080_______________1906______________T1080_______________1 |
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2013-10-21 : 14:03:53
|
select partno, warehouse, count(*) as occurencefrom yourtablegroup by partno, warehouseTara KizerSQL Server MVP since 2007http://weblogs.sqlteam.com/tarad/ |
|
|
James K
Master Smack Fu Yak Hacker
3873 Posts |
Posted - 2013-10-21 : 14:03:59
|
[code]SELECT PartNo, Warehouse, COUNT(*) As OccurenceFROM YourTableGROUP BY PartNo, Warehoue;[/code] |
|
|
|
|
|