View Full Version : Evil, EVIL report !


Guillaume777
05-08-2006, 06:28 PM
Say my table looks like this

Name Hours Wages per hour

John 7 7,75$
John 9 7,75$
John 10 8,75$
John 2 8,75$
Mary 3 7,75$
Mary 4 10,75$

How do I make the reports look like this :

Name Total hours Wages per hour

John 16 7,75$
John 12 8,75$
Mary 3 7,75$
Mary 4 10,75$


I know how to calculate the total hours of someone, but how do I show the data on separate lines and calculate the separate totals when the wages per hour aren't the same ?

Pat Hartman
05-08-2006, 07:54 PM
Select [Name], Sum(Hours) As SumHours, [Wages per hour]
From YourTable
Group By [Name], [Wages per hour];

Guillaume777
05-09-2006, 08:26 AM
Thanks, it works ! :)

However if I change

Select [Name], Sum(Hours) As SumHours, [Wages per hour] From YourTable Group By [Name], [Wages per hour];

to

Select [Name], Sum(Hours) As SumHours, [Wages per hour] From YourTable

or to

Select [Name], Sum(Hours) As SumHours, [Wages per hour] From YourTable Group By [Name]

It gives me errors !!! How come I can't change it without it giving me errors ?

KeithG
05-09-2006, 08:31 AM
you have to use one of the totals function on each of the fields.

Pat Hartman
05-09-2006, 01:56 PM
Also, I forgot to mention last night - "Name" is a poor choice as a column name. You WILL run into problems with it if you need to work with VBA. You should always avoid reserved words (you can find a list in help) since they cause confusion when you attempt to use VBA. Most common culprets are - Name, Date, Time, Month, Year, Value, Text.

So, if it is short and simply, it is probably reserved. Use prefixes and suffixes to solve the problem - CustName, LastName, FirstName, TransactionDate, HireDate, etc.

Guillaume777
05-09-2006, 06:47 PM
Thanks for the help, and I will never use "Name" again as a column name