Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Query Help

Status
Not open for further replies.

jimache

Programmer
Feb 26, 2003
15
US
Hi everyone,

I am new to Sql queries and I need help with a kind of simple query. I need to get the Total Sales by Sales Rep by Fiscal Quarter. I the tables that i am using are
[ORDERS]
order_id longint
order_date date
sales_rep_id longint
company_id longint
status alpha 20

[ORDER_LINE_ITEMS]
order_id longint
sku_code alpha 20
description text
quantity longint
unit_price real
pre_tax_total real
tax real
total real


[SALES_REPS]
FIELD_NAME TYPE
sales_rep_id longint
sales_rep_name alpha 20
sales_region alpha 20
sales_division alpha 20
How can i group orders based on fiscal quarter(Eg. Q1 - Jan - May, Q2 - june-august etc), over multiple years... when i have their dates ... (brain fried here). Any sugestion is appreciated.

Thank you,
 
Code:
SELECT cast((((MONTH(MyDate)-1)/3)+1) as int) AS Quarter


Borislav Borissov
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top