0

I have a data table with the following:

Price | Date | Quantity 20 | 01-02 | 1 20 | 01-03 | 2 30 | 01-01 | 2 30 | 01-03 | 1 40 | 01-02 | 3

For each row, I would like to be able to multiple the value of the "Price" column with the same row's Quantity value, then sum those values, and return a single value to determine total revenue for the month.

Here is what I have, but I keep getting stymied:

select sum( Select ("Price"*"Quantity") as "Subtotal") as "Total" from Sales where "Date" between '01/01/2016' and '01/31/2016';

However, this doesn't appear to do the trick. Does somebody know how I might tweak it to get the result I want?

1 Answer 1

2

Try this:

select sum("Price"*"Quantity") as "Total"
from Sales
where "Date" between '2016-01-01' and '2016-01-31';

You can directly apply sum on the product of "Price", "Quantity" fields. The above query returns a single row.

Demo here

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.