Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 Database Design and Application Architecture
 Harvesting Sales Data From Flat Table

Author  Topic 

SoleAris
Starting Member

3 Posts

Posted - 2015-03-11 : 16:02:09
Hi all,

I have a sales table that contains the records for all sales data and am having trouble figuring out the best way to harvest it for summations for reports, etc. My difficulty comes from the table being arranged with additional columns added for each month's sales as opposed to a "Sales" and "Month" column only. This allows for far less records, however I am not used to working with this type of table.

How I go about this is crucial as it acts as my Fact Table which my database will be designed around.

Should I just create queries to select only sales from one month and use the results of those 12 queries from there? There must be a more efficient way to do this.



Please help!

gbritton
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2015-03-11 : 16:14:47
1. Import the flat file into a staging table. (SSIS import/export wizard is one good way to do this)
2. Load the target table from the staging table, summarizing the data to fit the target columns

If you provide some examples of the input data (flat file) and target table schema, we can work up some simple queries to do the work.
Go to Top of Page

SoleAris
Starting Member

3 Posts

Posted - 2015-03-11 : 18:41:36
The flat file column structure looks as follows:

Year
Customer
ProductType
ItemNumber
Sales_Period_1
Sales_Period_2
Sales_Period_3
Sales_Period_4
Sales_Period_5
Sales_Period_6
Sales_Period_7
Sales_Period_8
Sales_Period_9
Sales_Period_10
Sales_Period_11
Sales_Period_12
Sales_Period_13


Whereas my Fact Table condenses the fields:

Year
Customer
ProductType
ItemNumber
Period
Sales


I do realize that I've had this data in this Fact Table format for years now and am probably so used to it in this schema that I cannot easily see how to work with the flat table easily.
Go to Top of Page

gbritton
Master Smack Fu Yak Hacker

2780 Posts

Posted - 2015-03-11 : 19:11:03
Do you mean that the flat file has each sales period on a new line or have you rotated the columns to make posting easier?
Go to Top of Page
   

- Advertisement -