Home All Groups Group Topic Archive Search About

Need help with Month / Year Query

Author
22 Dec 2005 3:57 PM
Gomi
I have a table with order dates for the past few years. I am trying to
write a query that just ives me a distinct month/year for all the
orders so that I can do my reports monthly. I have been wracking my
brains over this one for the past few days and just can't seem to get
it.

Basically what I need is a way to get a distinct month/year from
OrderDate.

Thanks for the help in advance

Author
22 Dec 2005 4:04 PM
Raymond D'Anjou
"Gomi" <wy***@wyattf.com> wrote in message
news:1135267024.962663.204530@g43g2000cwa.googlegroups.com...
>I have a table with order dates for the past few years. I am trying to
> write a query that just ives me a distinct month/year for all the
> orders so that I can do my reports monthly. I have been wracking my
> brains over this one for the past few days and just can't seem to get
> it.
>
> Basically what I need is a way to get a distinct month/year from
> OrderDate.
>
> Thanks for the help in advance

select year(dateOrder), month(dateOrder)
from orders
group by year(dateOrder), month(dateOrder)
order by year(dateOrder), month(dateOrder)

OR

select distinct year(dateOrder), month(dateOrder)
from orders
order by year(dateOrder), month(dateOrder)
Author
22 Dec 2005 4:12 PM
Gomi
I cannot believe it was that simple. Thank you. I blame it all on me
looking forward to a week off for the holidays
Author
22 Dec 2005 4:20 PM
Grant
Happy holidays then.....



Show quote
"Gomi" <wy***@wyattf.com> wrote in message
news:1135267975.117003.281660@g14g2000cwa.googlegroups.com...
>I cannot believe it was that simple. Thank you. I blame it all on me
> looking forward to a week off for the holidays
>
Author
22 Dec 2005 5:04 PM
Raymond D'Anjou
"Gomi" <wy***@wyattf.com> wrote in message
news:1135267975.117003.281660@g14g2000cwa.googlegroups.com...
>I cannot believe it was that simple. Thank you. I blame it all on me
> looking forward to a week off for the holidays

Glad to help.
Maybe you can give me a few of those days off.

AddThis Social Bookmark Button