Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Extract the data based on the present quarter and last quarter Expand / Collapse
Author
Message
Posted Monday, December 16, 2013 10:44 AM
SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: 2 days ago @ 6:51 AM
Points: 201, Visits: 1,144
How to
Extract the data based on the present quarter and last quarter in SQL

Please let me know

Regards,
Praveen
Post #1523344
Posted Monday, December 16, 2013 10:55 AM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Yesterday @ 2:04 PM
Points: 3,572, Visits: 8,008
There's not enough information to help you.
Please post DDL, sample data and expected results as explained on the article linked in my signature.
We're willing to help but we can't see what you see.



Luis C.
Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

Forum Etiquette: How to post data/code on a forum to get the best help
Post #1523350
Posted Tuesday, December 17, 2013 6:10 AM
Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Today @ 11:54 AM
Points: 3,971, Visits: 3,411
You're going to need to use the DATEPART function to determine the quarter for the date on which you're basing the distribution. http://msdn.microsoft.com/en-us/library/ms174420%28v=sql.100%29.aspx. Other than that, Luis is right - we don't know anything about your table structure or what you're trying to do. Please post DDL, DML to populate sample data and what you've tried so far.


Tally Tables - Performance Personified
String Splitting with True Performance
Best practices on how to ask questions
Post #1523652
Posted Tuesday, December 17, 2013 7:24 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: 2 days ago @ 2:34 PM
Points: 12,923, Visits: 12,342
Here are some excellent ways to get a number of different datetime values. http://www.sqlservercentral.com/blogs/lynnpettis/2009/03/25/some-common-date-routines/


_______________________________________________________________

Need help? Help us help you.

Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

Need to split a string? Try Jeff Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1523678
Posted Tuesday, December 17, 2013 1:36 PM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Yesterday @ 10:28 PM
Points: 35,215, Visits: 31,666
Smash125 (12/16/2013)
How to
Extract the data based on the present quarter and last quarter in SQL

Please let me know

Regards,
Praveen


 SELECT TheData
FROM dbo.SomeTable
WHERE SomeDateColumn >= DATEADD(qq,DATEDIFF(qq,0,GETDATE())-1,0)
;



--Jeff Moden
"RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row".

First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."

(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #1523872
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse