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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 Database Design and Application Architecture
 Harvesting Sales Data From Flat Table
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

SoleAris
Starting Member

USA
3 Posts

Posted - 03/11/2015 :  16:02:09  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

2780 Posts

Posted - 03/11/2015 :  16:14:47  Show Profile  Reply with Quote
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

USA
3 Posts

Posted - 03/11/2015 :  18:41:36  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

2780 Posts

Posted - 03/11/2015 :  19:11:03  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.03 seconds. Powered By: Snitz Forums 2000