[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 478
  • Last Modified:

SQL - sum of rows in a new row?

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
NO_CARRIER
Asked:
NO_CARRIER
1 Solution
 
omgangCommented:
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
 
NO_CARRIERAuthor Commented:
Awesome, exactly what I was looking for... (and they said it couldn't be done, ha!)
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now