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 613101
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T17:57:56+00:00 2026-05-13T17:57:56+00:00

I have a table like this; ID int, OrderedDate DateTime I want to select

  • 0

I have a table like this;

ID int,
OrderedDate DateTime

I want to select only records of followed month.

For example result set:

ID    OrderedDate

110    January
110    February
200    January
200    February

How can I write this query?

  • 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-05-13T17:57:57+00:00Added an answer on May 13, 2026 at 5:57 pm

    I think you want list of months that ID has orders in but with the months sorted by the month number instead of the name?

    create table test21210
    (
        id int,
        OrderedDate datetime
    )
    go
    
    insert test21210 (id, OrderedDate) values (110, '1/1/2010')
    insert test21210 (id, OrderedDate) values (110, '1/5/2010')
    insert test21210 (id, OrderedDate) values (110, '1/10/2010')
    insert test21210 (id, OrderedDate) values (110, '2/2/2010')
    insert test21210 (id, OrderedDate) values (110, '2/4/2010')
    insert test21210 (id, OrderedDate) values (110, '2/6/2010')
    
    insert test21210 (id, OrderedDate) values (200, '1/3/2010')
    insert test21210 (id, OrderedDate) values (200, '1/5/2010')
    insert test21210 (id, OrderedDate) values (200, '1/7/2010')
    insert test21210 (id, OrderedDate) values (200, '1/9/2010')
    insert test21210 (id, OrderedDate) values (200, '2/3/2010')
    insert test21210 (id, OrderedDate) values (200, '2/5/2010')
    insert test21210 (id, OrderedDate) values (200, '2/7/2010')
    insert test21210 (id, OrderedDate) values (200, '2/9/2010')
    go
    
    with idmonth (id, MonthNumber) as
    (
        select id, MONTH(ordereddate) as 'MonthNumber'
        from test21210
        group by id, MONTH(ordereddate)
    )
    select id, DATENAME(MONTH, STR(MonthNumber)+'/1/2000')
    from idmonth
    order by id, MonthNumber
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a testdata like this: DROP TABLE SELECT_PASS; CREATE TABLE SELECT_PASS(ID INT(20),TESTCASE VARCHAR(20),RESULT
I have a table that looks like this: ------------------------------------------------------------------- CUSTNUM (INT), ITEMNUM (INT), MONTH
What I want to do is have a table structure like this: TypeID int
I have table like this create table tbl_1( year int, month int, day int
I have a table OrganisationStructure like this: OrganisationID INT ParentOrganisationID INT OrganisationName VARCHAR(64) 1
Assume I have a table like this: column A(int) column B(int) 1 2 2
I have a table that looks like this: ID (pk,int) Col1 (nvarchar) Col2 (nvarchar)
I have a MySQL table that looks like this: `id` int(10) unsigned NOT NULL
I have two tables which looks something like this Table Queue int ID; string
I have something like this: create table account ( id int identity(1,1) primary key,

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.