Solved

MySQL won't show results as DESC?

Posted on 2012-04-05
4
381 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Creating and Managing Databases with phpMyAdmin in cPanel.
Many old projects have bad code, but the budget doesn't exist to rewrite the codebase. You can update this code to be safer by introducing contemporary input validation, sanitation, and safer database queries.
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 dynamically set the form action using jQuery.

726 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