Solved

SQL - sum of rows in a new row?

Posted on 2008-10-01
2
471 Views
Last Modified: 2012-08-13
Hi.. I have a table with 6 rows/records of data.
The last three rows I would like summerized into a separate record with a make-table query, is this possible?

Basically, everytime I run the report I need to combine
Company B, Account 2
Company B, Account 1
Company B, Account 0

into a separate row.

Company	Account	Max Price
D	4	126
A	4	1205
A	0	519
C	4	308
C	0	55
B	4	440
B	3	20
B	2	171
B	1	95
B	0	2318

Open in new window

0
Comment
Question by:NO_CARRIER
2 Comments
 
LVL 28

Accepted Solution

by:
omgang earned 75 total points
ID: 22616948
Are you looking for something like this?

SELECT Company, IIf([Company]="B" And [Account] In ("0","1","2"),"B2",[Account]) AS Acct, Sum(Max_Price) AS SumOfMax_Price
FROM MyTable
GROUP BY Company, IIf([Company]="B" And [Account] In ("0","1","2"),"B2",[Account]);

OM Gang
0
 
LVL 1

Author Comment

by:NO_CARRIER
ID: 22623639
Awesome, exactly what I was looking for... (and they said it couldn't be done, ha!)
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

If you find yourself in this situation “I have used SELECT DISTINCT but I’m getting duplicates” then I'm sorry to say you are using the wrong SQL technique as it only does one thing which is: produces whole rows that are unique. If the results you a…
If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
In a recent question (https://www.experts-exchange.com/questions/28997919/Pagination-in-Adobe-Acrobat.html) here at Experts Exchange, a member asked how to add page numbers to a PDF file using Adobe Acrobat XI Pro. This short video Micro Tutorial sh…

821 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