question

AngelSun avatar image
AngelSun asked

Trying to write a SQL query to display only the “part number” with multiple warehouse “locations”

Trying to write a SQL query to display only the "part number" with multiple warehouse "locations". I want a search that will display each "partno" that has more than one "boxSize" and/or "boxLocation". There is only one table where the data that I need resides. SELECT DISTINCT partno, COUNT(partno) AS MULTIPLE_PARTNO FROM [Reports].[dbo].[Data_all] GROUP BY partno HAVING COUNT(partno) <> '1'
sql-server-2008sql
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

1 Answer

·
eaglescout avatar image
eaglescout answered
Great question! Try This: SELECT partno, boxSize, Count(partno) as MULTIPLE_PARTNO FROM [Reports].[dbo].[Data_all] WHERE partno IN (SELECT partno FROM [Reports].[dbo].[Data_all] GROUP BY partno HAVING COUNT (partno) >1) This is assuming that PartNo only appears more then once when it has more then 1 boxSize. Let me know if that works.
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.