SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 Script Library
 Ordering by months
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

s_a19
Starting Member

15 Posts

Posted - 06/09/2004 :  09:50:07  Show Profile  Reply with Quote
I am wondering if someone maybe able to help me, I am needing to order my data via months in the calendar sense not alphabetically, below is what I currently have, but it only does it alphabetically.

select to_char(created,'yyyy-Mon'), matdesc, count(*)
from test
group by to_char(created,'yyyy-Mon'), matdesc
order by to_char(created,'yyyy-Mon') desc

any help would be greatly appreciated

Thank you

Stephen

Seventhnight
Flowing Fount of Yak Knowledge

USA
2878 Posts

Posted - 06/09/2004 :  09:52:04  Show Profile  Visit Seventhnight's Homepage  Reply with Quote
try:

select to_char(created,'yyyy-Mon'), matdesc, count(*)
from test
group by to_char(created,'yyyy-Mon'), matdesc
order by year(created), month(created)


Corey

Edited by - Seventhnight on 06/09/2004 09:53:03
Go to Top of Page

s_a19
Starting Member

15 Posts

Posted - 06/09/2004 :  10:27:33  Show Profile  Reply with Quote
thank you,
it doesnt seem to like the fields year and month,
its complaining that they arent in the table and its saying invalid column name.
any ideas?
Go to Top of Page

raymondpeacock
Constraint Violating Yak Guru

United Kingdom
367 Posts

Posted - 06/09/2004 :  10:32:53  Show Profile  Reply with Quote
The functions MONTH and YEAR are valud SQL Server T-SQL function calls. Are you running this against a SQL Server database?


Raymond
Go to Top of Page

s_a19
Starting Member

15 Posts

Posted - 06/09/2004 :  10:49:42  Show Profile  Reply with Quote
it appears not
i do apologise
Go to Top of Page

raymondpeacock
Constraint Violating Yak Guru

United Kingdom
367 Posts

Posted - 06/09/2004 :  10:50:33  Show Profile  Reply with Quote
No problem! The to_char function was the giveaway...


Raymond
Go to Top of Page

s_a19
Starting Member

15 Posts

Posted - 06/09/2004 :  11:06:29  Show Profile  Reply with Quote
would you be able to recommend a suitable forum
for the problem please

thanks
Go to Top of Page

raymondpeacock
Constraint Violating Yak Guru

United Kingdom
367 Posts

Posted - 06/09/2004 :  11:07:59  Show Profile  Reply with Quote
Probably not! What language are you using?


Raymond
Go to Top of Page

s_a19
Starting Member

15 Posts

Posted - 06/09/2004 :  11:21:56  Show Profile  Reply with Quote
PL/SQL

Stephen
Go to Top of Page

raymondpeacock
Constraint Violating Yak Guru

United Kingdom
367 Posts

Posted - 06/09/2004 :  11:28:27  Show Profile  Reply with Quote
Then you'd better try an Oracle forum.


Raymond
Go to Top of Page

X002548
Not Just a Number

15586 Posts

Posted - 06/09/2004 :  11:30:54  Show Profile  Reply with Quote
[dusting off oracle books]
Did you Try MM

Do you have a manual...I know the formats are in there

[/dusting off oracle books]



Brett

8-)
Go to Top of Page

s_a19
Starting Member

15 Posts

Posted - 06/10/2004 :  04:18:42  Show Profile  Reply with Quote
thank you

for dusting of those books,

it appears to work
Go to Top of Page
  Previous Topic Topic Next Topic  
 New 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.07 seconds. Powered By: Snitz Forums 2000