?
Solved

SQL Server Compute Statement

Posted on 2009-02-11
2
Medium Priority
?
296 Views
Last Modified: 2012-05-06
The COMPUTE statement in this sproc gives me the following error when I attempt to save it in design mode.
Compute Clause #1, aggregate expression #1 is not in the select list

Can anyone tell me why? My objective is to get a sum of the GB and TB columns from the select statement as grand totals for all derivatives.
Thank you... Herb
SELECT DerivativeType , COUNT(DerivativeKey) AS DerivativeCount, SUM(GB) AS GB, SUM(TB) AS TB 
FROM Derivatives 
WHERE ShipmentKey = @ShipmentKey AND QCPerson = 0
GROUP BY DerivativeType
COMPUTE COUNT(DerivativeKey), SUM(GB), SUM(TB)

Open in new window

0
Comment
Question by:stullhe104
2 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 1000 total points
ID: 23611826
try this instead:
SELECT DerivativeType , COUNT(DerivativeKey) AS DerivativeCount, SUM(GB) AS GB, SUM(TB) AS TB 
FROM Derivatives 
WHERE ShipmentKey = @ShipmentKey AND QCPerson = 0
GROUP BY DerivativeType
WITH ROLLUP

Open in new window

0
 

Author Closing Comment

by:stullhe104
ID: 31545564
Thanks a bunch. That worked like a charm!
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you having speed problem in loading SQL Server Management Studio, try to uncheck these options in your internet browser (IE -> Internet Options / Advanced / Security):    . Check for publisher's certificate revocation    . Check for server ce…
When writing XML code a very difficult part is when we like to remove all the elements or attributes from the XML that have no data. I would like to share a set of recursive MSSQL stored procedures that I have made to remove those elements from …
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…
Suggested Courses

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question