Reputation: 21
I have a table that looks like so
ACCOUNT AMOUNT
Income 59
Income 69
Income 99
Income 45
COGS 43
COGS 34
COGS 45
Expense 44
Expense 55
I want to insert a row into this table that will have the ACCOUNT value=Gross Profit
and the AMOUNT Value = SUM(Income and COGS)
Upvotes: 1
Views: 1502
Reputation: 11556
Use an INSERT ... SELECT Syntax
Query
INSERT INTO tblName(ACCOUNT, AMOUNT)
SELECT 'Gross Profit',
SUM(AMOUNT)
FROM tblName
WHERE ACCOUNT IN ('Income', 'COGS');
Upvotes: 2