Hi again was just wondering what the best way is too write a script too write a script to record a sale of a workofart? into Sales and WorkOfArt Tables?
Thx :confused:I'm not sure I understand what you want, so we'll start with:INSERT INTO Sales (column_list1) VALUES (column_values1)
INSERT INTO Workofart (column_list2) VALUES (column_values2)I must be missing something, this seems way too easy.
-PatP
Showing posts with label sale. Show all posts
Showing posts with label sale. Show all posts
Monday, March 26, 2012
Wednesday, March 21, 2012
How to Include months not in the records?
Hi,
I have 2 tables created.
One is the Sale Persons (PersonID, PersonName) and the other is the Sales Detail (PersonID, Month, Year, TotalSales)
PersonID | PersonName PersonID | Month | Year | Total Sales
================== ==================================
ID1 | Sally ID1 | 1 | 2005 | 1000
ID2 | David ID2 | 2 | 2005 | 1500
Is it possible to write in a SQL statement to return all the sales person & the total sales for the 12 months for a particular year (even though some month data are not in the table)
I would like the result to be like the following:
PersonID | Month | Year | Total Sales
===================================
ID1 | 1 | 2005 | 1000
ID1 | 2 | 2005 | 0
ID1 | 3 | 2005 | 0
(For month 4 - 12) Total Sales will be 0 too as no records exist in the first place
ID2 | 1 | 2005 | 0
ID2 | 2 | 2005 | 1500
........
Do you have to do it in SQL or can you do it in code?|||
I have 2 tables created.
One is the Sale Persons (PersonID, PersonName) and the other is the Sales Detail (PersonID, Month, Year, TotalSales)
PersonID | PersonName PersonID | Month | Year | Total Sales
================== ==================================
ID1 | Sally ID1 | 1 | 2005 | 1000
ID2 | David ID2 | 2 | 2005 | 1500
Is it possible to write in a SQL statement to return all the sales person & the total sales for the 12 months for a particular year (even though some month data are not in the table)
I would like the result to be like the following:
PersonID | Month | Year | Total Sales
===================================
ID1 | 1 | 2005 | 1000
ID1 | 2 | 2005 | 0
ID1 | 3 | 2005 | 0
(For month 4 - 12) Total Sales will be 0 too as no records exist in the first place
ID2 | 1 | 2005 | 0
ID2 | 2 | 2005 | 1500
........
Do you have to do it in SQL or can you do it in code?|||
Create a temporary table using a sql proc or in code that contains the year(s) and months that you do want to include. Then you just have to OUTER join it to your existing tables to fill in the missing gaps.
HTH.
Subscribe to:
Posts (Atom)