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.
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 columnsIf 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. |
|
|
SoleAris
Starting Member
3 Posts |
Posted - 2015-03-11 : 18:41:36
|
The flat file column structure looks as follows:YearCustomerProductTypeItemNumberSales_Period_1Sales_Period_2Sales_Period_3Sales_Period_4Sales_Period_5Sales_Period_6Sales_Period_7Sales_Period_8Sales_Period_9Sales_Period_10Sales_Period_11Sales_Period_12Sales_Period_13Whereas my Fact Table condenses the fields:YearCustomerProductTypeItemNumberPeriodSalesI 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. |
|
|
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? |
|
|
|
|
|