I'm a novice SQL programmer. I'm trying to write a SQL query
and would appreciate any help. This is the jist of what I'm trying to do.
Let's say I'm an amazon.com customer (not my exact scenario, but close enough)
I have all my billing history in a table, say BILL_HISTORY...
I want to find out all the orders I have placed in the previous month (1 row for each order in this period) and
the value of sum of all the orders that I placed.
ie., something like this...
bill_amt, sum (bill_amt)
bill_date between <#start_date#> and <#end_date#>
Now, the above query would give me a sum that is the amount ($$) ordered
during the specified period (dates). However, my intention
is to get total amount ordered for from the date I first purchased anything at amazon.com
select person, bill_amt, view1.total_amt
from bill_history, (select person, sum(bill_amt) total_amt
from bill_history) view1
where bill_history.person = view1.person
and bill_date between <#start_date#> and <#end_date#>
This will only give you information for people with transactions between <#start_date#> and <#end_date#>.