Grouping with Sum Query

S

SteveR

I have a table that contains the following fields.

PrinterName Project Width Length TotalPrints
Xerox510 High Rise 36 48 10


I need to find the total Square Footage printed by project. I'm a bit lost
when it comes to grouping etc. Here is what I have so far which doesn't work.

Select PrinterName, Project, ((width * Length / 144)*TotalPrints) as SqFt
From Joblog
Where Printername = 'xerox510'
Group By Project Sum(SqFt)

Thanks

Steve
 
C

Clifford Bass

Hi Steve,

Try:

Select Project, Sum((width * Length / 144)*TotalPrints) as SqFt
From Joblog
Where Printername = 'xerox510'
Group By Project

Clifford Bass
 
S

SteveR

I think I got it figured out. Here is what I came up with. So far it seems to
work.

SELECT ProjectName, sum(SqFt)As TotalSqFt
FROM (select ProjectName, PrinterName,((Width * Length / 144)*
TotalPrints) AS SqFt From JobLog where PrinterName = 'SXEROX510PS')as Test
Group by ProjectName;

Thanks for the response

Steve
 
C

Clifford Bass

Hi Steve,

With that you are making it more complicated than it needs to be. Did
you try my solution?

Clifford Bass
 
S

SteveR

I tried your solution and although it ran without errors it didn't return any
information.
 
C

Clifford Bass

Hi Steve,

I see that you use different a different project column name and a
different printer name in your second statement from the one you orginally
posted. That may account for it. If you did not do so, try adjusting my
example to use the correct column and printer names.

Clifford Bass
 
S

SteveR

I had adjusted the ProjectName field but missed the Printer name. That fixed
it! Your way is much easer!

Thanks!

Steve
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top