Solved

MySQL won't show results as DESC?

Posted on 2012-04-05
4
373 Views
Last Modified: 2012-04-05
I'm simply trying to display the query below in date DESC so 2012 is at the top but for some reason it's displaying ASC?

I have used the same code on another pretty much identical database fine. Any ideas why this isn't working?

SELECT id, YEAR(`eventdate`) AS 'year', MONTH(`eventdate`) AS 'month', COUNT(`id`) AS 'count'  FROM `news` GROUP BY YEAR(`eventdate`), MONTH(`eventdate`) ORDER BY YEAR('eventdate') DESC, MONTH('eventdate') DESC

Open in new window

Screen-shot-2012-04-05-at-13.18..png
Screen-shot-2012-04-05-at-13.22..png
0
Comment
Question by:BrighteyesDesign
  • 2
4 Comments
 
LVL 42

Expert Comment

by:sedgwick
ID: 37810844
try run the query without the id, do u get descending results?

SELECT  YEAR(`eventdate`) AS 'year', MONTH(`eventdate`) AS 'month' FROM `news` GROUP BY YEAR(`eventdate`), MONTH(`eventdate`) ORDER BY YEAR('eventdate') DESC, MONTH('eventdate') DESC
0
 

Author Comment

by:BrighteyesDesign
ID: 37810941
Still the same? very strange.
Screen-shot-2012-04-05-at-14.01..png
0
 
LVL 24

Accepted Solution

by:
johanntagle earned 500 total points
ID: 37811286
Can you try ORDER BY 1 DESC, 2 DESC ?  The numbers refer to the columns in the SELECT clause.
0
 

Author Closing Comment

by:BrighteyesDesign
ID: 37811412
Thanks a million, works perfectly now
0

Featured Post

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
This article discusses how to create an extensible mechanism for linked drop downs.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now