Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9013205
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T03:12:05+00:00 2026-06-16T03:12:05+00:00

My query is USE MyDB SELECT DATENAME(DD, s.requestdate) FROM sample_table s WHERE MONTH(s.requestdate) =

  • 0

My query is

USE MyDB

SELECT DATENAME(DD, s.requestdate)
FROM   sample_table s
WHERE  MONTH(s.requestdate) = 12
GROUP  BY DATENAME(DD, s.requestdate)
ORDER  BY DATENAME(DD, s.requestdate) DESC 

The output I expect is to be ordered by day of month in descending order but my output is ordered such

9
8
 7....till 1 then 19, 18...till 11

What am I missing?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T03:12:06+00:00Added an answer on June 16, 2026 at 3:12 am

    DATENAME returns a string.

    Use DATEPART(DD,s.requestdate) instead as that returns an integer and will sort as you expect.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use this query: $result_members = mysql_query(SELECT * FROM members); The results are displayed
Dictionary<string, DataRow> dtUsers; using (DataSet dsmyTable = DbConnection.db_Select_Query (use myDb select * from myTable))
Can a select query use different indexes if a change the value of a
I am getting some data from my database table. The query I use is
I want to use a query like: sql(select name where id > 10 and
I get data from my DB using cursor = db.query(WebLeadMaster, select, condition1=+conditionVal1+ and condition2=+ConditionVal2,null,
select log_reuse_wait_desc from sys.databases where name = 'mydb' 1. LOG_BACKUP All update and insert
I use query string to access my pages. I try to make if anyone
I see how you can use query functions to apply different weights to different
Anyone know the syntax for writing a php-mongo query to use NOT NULL ?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.