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
 SQL Server 2005 Forums
 Transact-SQL (2005)
 t-sql on rolling 3 month period
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

ziggy2015
Starting Member

United Kingdom
11 Posts

Posted - 04/12/2015 :  07:15:15  Show Profile  Reply with Quote
Hi Guys,

I need your help on how to write sql on months total sales volume and variance.

I want to calculate 3 months from today excluding the current month as I there is no data.

Thanks

Ziggy

gbritton
Flowing Fount of Yak Knowledge

2780 Posts

Posted - 04/12/2015 :  14:27:42  Show Profile  Reply with Quote
please post your table definition (CREATE TABLE statement), some sample data (as INSERT INTO commands) and your desired results, using the sample data
Go to Top of Page

ziggy2015
Starting Member

United Kingdom
11 Posts

Posted - 04/13/2015 :  02:53:16  Show Profile  Reply with Quote
Thanks. My table looks like:

Select Year
,Month
,Date
,Sum(Total) As Count
,OrganizationCode
,ProviderCode

From TblVolume
Group by Year
,Month
,Date
,OrganizationCode
,ProviderCode

I need a three months rolling period and comparing current month and previous 2 months.

Thanks
Go to Top of Page

gbritton
Flowing Fount of Yak Knowledge

2780 Posts

Posted - 04/13/2015 :  08:56:25  Show Profile  Reply with Quote
Please post the other requested items:

1. CREATE TABLE statement (that is NOT a select statement)
2. INSERT INTO statements to populate the table with test data
3. Your desired results, using the table and test data from steps 1 and 2
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.02 seconds. Powered By: Snitz Forums 2000