Hi to all.
I'm new with SQL. I need to build a query that reports data from the previous two (2) or five (5) or n days.
I think is better explain the scenario with an example:
Database Name: db_rec_ss
View Name: is_vrec
Tables associated in views: is_reg, is_bill, is_items
The view (is_vrec) groups data in this format (simplified as I can):
id_item | desc_item | totalsell_ammount | date
01 | Blue book | 21.00 | 10/2/2008
02 | Red book | 34.00 | 10/2/2008
01 | Blue book | 10.00 | 10/3/2008
02 | Red book | 32.00 | 10/3/2008
01 | Blue book | 25.00 | 10/4/2008
02 | Red book | 15.00 | 10/4/2008
01 | Blue book | 12.00 | 10/5/2008
02 | Red book | 10.00 | 10/5/2008
Ok.. you got it..!
I need to build a SQL query that retrieves the data from the previous 2 days, in this format: (For the example today is 10/5/2008)
id_item | desc_item | 10/4/2008 | 10/3/2008
01 | Blue book | 25.00 | 10.00
02 | Red book | 15.00 | 32.00
An important tip is that non-work days, doesn't generate data. I think this simplified the query, because I only need that the query retrieves the last n days. Doesn't important to calculate if is work or non-work day.
I don't want to import data on an Excel worksheet.
With the information supplied, can U help me?
Thanks a lot in advance for your help...!