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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T18:20:31+00:00 2026-05-31T18:20:31+00:00

Something like: SELECT MONTH(*date?*) FROM //Not sure what goes here LIMIT 0,6 I know

  • 0

Something like:

SELECT MONTH(*date?*)
  FROM 
   //Not sure what goes here
LIMIT 0,6

I know its simple, but I want to know how to get a list of the last six months in case i ever need to Join to it. Useful if getting past data and using:

IFNULL(data, 0)

  • 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-31T18:20:32+00:00Added an answer on May 31, 2026 at 6:20 pm
    select month(DATE_SUB(now(), INTERVAL 6 MONTH)) month_6,
           month(DATE_SUB(now(), INTERVAL 5 MONTH)) month_5,
           month(DATE_SUB(now(), INTERVAL 4 MONTH)) month_4,
           month(DATE_SUB(now(), INTERVAL 3 MONTH)) month_3,
           month(DATE_SUB(now(), INTERVAL 2 MONTH)) month_2,
           month(DATE_SUB(now(), INTERVAL 1 MONTH)) month_1
    

    OUTPUT

    month_6 month_5 month_4 month_3 month_2 month_1
          9      10      11      12       1       2
    

    If you want it to include the current month, then just start with 5 and go to 0 instead of 6 to 1.

    If you want rows, do this:

    select        month(DATE_SUB(now(), INTERVAL 6 MONTH))
    union  select month(DATE_SUB(now(), INTERVAL 5 MONTH))
    union  select month(DATE_SUB(now(), INTERVAL 4 MONTH))
    union  select month(DATE_SUB(now(), INTERVAL 3 MONTH))
    union  select month(DATE_SUB(now(), INTERVAL 2 MONTH))
    union  select month(DATE_SUB(now(), INTERVAL 1 MONTH))
    

    OUTPUT

    9
    10
    11
    12
    1
    2
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

The SQL would be something like select GeneralData.id, GeneralData.name, GeneralData.last_name, Student.id from GeneralData Inner
I would like to run something like: select * from table where field in
When I attempt to do something like SELECT Max(ObjectId) FROM Objects; I see that
I have to join queries from multiple databases, something like: SELECT T1.*, T2.* FROM
I'm looking for something like this: SELECT german_subsidiaries.*, customers.* FROM german_subsidiaries INNER JOIN customers
let's say mysql is something like this select x,y from xx group by y
How do I do something like the following SELECT ADDDATE(t_invoice.last_bill_date, INTERVAL t_invoice.interval t_invoice.interval_unit) FROM
In MySQL, I can do something like: SELECT DATE_ADD('2010-07-02', INTERVAL 1 MONTH) And that
I have a stored procedure which basically does something like select top 1 expiryDate,
I'd like to achieve something like this: SELECT (CASE WHEN ...) AS FieldA, FieldA

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.