Solved

MySQL won't show results as DESC?

Posted on 2012-04-05
4
388 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

Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

Question has a verified solution.

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

This article shows the steps required to install WordPress on Azure. Web Apps, Mobile Apps, API Apps, or Functions, in Azure all these run in an App Service plan. WordPress is no exception and requires an App Service Plan and Database to install
In this series, we will discuss common questions received as a database Solutions Engineer at Percona. In this role, we speak with a wide array of MySQL and MongoDB users responsible for both extremely large and complex environments to smaller singl…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
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…

724 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