Site Sponsored By: SQLDSC - SQL Server Desired State Configuration
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.
i need some help with this querry.I want to report the item_numer, description, and the total of quantity picked for the whole year.so i have this view, PickDetails(Item_number, Description, Pick_quantity, creation_date)when i run the following query i get reapeted rows--------------------------------------------select distinct item_number,description, sum(picked_quantity)as QTY from dbo.dbo_vPickDetails WHERE creation_date BETWEEN '2010-06-01' AND '2011-06-01'gROUP BY item_number,description,picked_quantityOrder by QTY DESCthis is the result20713 216 FIBER SINGLE-MODE AERIAL w/ LOOSE TUBE BUFFER 30503.000020713 216 FIBER SINGLE-MODE AERIAL w/ LOOSE TUBE BUFFER 25164.000020713 216 FIBER SINGLE-MODE AERIAL w/ LOOSE TUBE BUFFER 25114.000020713 216 FIBER SINGLE-MODE AERIAL w/ LOOSE TUBE BUFFER 25085.000020713 216 FIBER SINGLE-MODE AERIAL w/ LOOSE TUBE BUFFER 24081.000020713 216 FIBER SINGLE-MODE AERIAL w/ LOOSE TUBE BUFFER 13750.000020712 12 Strand Single Mode Aerial non amored fiber optic cable flexlink. 12524.000020297 48 FIBER SINGLE-MODE AERIAL W/LOOSE TUBE BUFFER NON - ARMOR PART# 0048HBS1AFESJA 7292.000020297 48 FIBER SINGLE-MODE AERIAL W/LOOSE TUBE BUFFER NON - ARMOR PART# 0048HBS1AFESJA 6180.000020712 12 Strand Single Mode Aerial non amored fiber optic cable flexlink. 6056.000020712 12 Strand Single Mode Aerial non amored fiber optic cable flexlink. 6014.000020713 216 FIBER SINGLE-MODE AERIAL w/ LOOSE TUBE BUFFER 5500.0000i get 7 records for item_numer 20713 i want to get 1 record and the sum of quantity20713 216 FIBER SINGLE-MODE AERIAL w/ LOOSE TUBE BUFFER 149197if you can help me would be nice
sunitabeck
Master Smack Fu Yak Hacker
5155 Posts
Posted - 2011-06-30 : 21:03:04
Remove picked_quantity from the GROUP BY clause:
select distinct item_number,description, sum(picked_quantity)as QTYfrom dbo.dbo_vPickDetails WHERE creation_date BETWEEN '2010-06-01' AND '2011-06-01'gROUP BY item_number,description ,picked_quantity