Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to delete the blank record 1

Status
Not open for further replies.
May 24, 2005
30
US
hi, I have a question about the Query,
For example, I have 3 field,
field 1 : ID
field 2: name
field 3: sales

my table is like this
ID name sales
1 aa 100
2 bb 400
3 cc 300
1 200
2 200

in the record of 4 and 5, there is no name, but it is the same with record 1 and 2. I suppose to sum the sales by name. so the output should be
ID name sales
1 aa 300
2 bb 600
3 cc 300

I know, I can make it easier by adding a table, but there are a lot of record, can I DO it by query?
thanks in advance!

Jeffery
 
SELECT ID, Max([name]) AS [Name], Sum(sales) AS Total
FROM yourTable
GROUP BY ID

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top