Get Order

Database

Get Order

ACCT_ID ACCT_NM ORD_NBR ORD_DT ORD_AMT_USD
595709114 ASDASD 44444 7/28/2014 546
2224809440 ASDASD 44444 5/2/2012 546
1724031572 ASDASD 44444 6/22/2011 546
1702887651 ASDASD 44444 7/3/2014 546
1724020508 ASDASD 44444 7/16/2012 546
1148151895 ASDASD 44444 9/18/2013 546
2125154824 ASDASD 44444 9/2/2014 546
1503552723 ASDASD 44444 12/20/2011 546
2224689808 ASDASD 44444 10/4/2010 546
931387698 ASDASD 44444 12/31/2010 546

I very new to TD. I need to get order details based on current quarter.Please help me how to work on this. I am providing sample data below

3 REPLIES

Re: Get Order

Current quarter of previous years too? I am a bit confused :)

Hope this calculation for  a quarter example below can help you:

select .......... ,((CAST(EXTRACT(MONTH FROM ORD_DT) AS BYTEINT)-1)/3)+1 as QUARTER from your_table where QUARTER=3

Re: Get Order

skip the cast, extract etc...

select blah, blah, blah, cal.quarter_of_year from yourtable yt inner join sys_calendar.calendar cal on (yt.orddt = cal.calendar_date);

the system calendar has quarter of year, quarter of calendar and a multitude of pre-calculated calendar items.

Cheers!

Re: Get Order

Yes it can be done in many ways. You can check the explain and see.