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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T03:49:27+00:00 2026-06-13T03:49:27+00:00

I have Table with columns: Month and Year, and other data. All row in

  • 0

I have Table with columns: “Month” and “Year”, and other data.

All row in Table have different values “Month” and “Year”.

But for some Month and Year rows don’t exist.

I want create SQL-query (… where year in (2010, 2011, 2012) …), that in result this SQL-query have all Month for select Year and if some month don’t exist else add it to result with 0 in other data columns.

Example:
Input: Table

data / month / year
+-----+---+------+
| 3.0 | 1 | 2011 |
| 4.3 | 3 | 2011 |
| 5.7 | 4 | 2011 |
| 2.2 | 5 | 2011 |
| 5.4 | 7 | 2011 |
+-----+---+------+

Output: SELECT … WHERE year IN (2011)

+-----+----+------+
| 3.0 |  1 | 2011 |
|   0 |  2 | 2011 |
| 4.3 |  3 | 2011 |
| 5.7 |  4 | 2011 |
| 2.2 |  5 | 2011 |
|   0 |  6 | 2011 |
| 5.4 |  7 | 2011 |
|   0 |  8 | 2011 |
|   0 |  9 | 2011 |
|   0 | 10 | 2011 |
|   0 | 11 | 2011 |
|   0 | 12 | 2011 |
+-----+----+------+
  • 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-13T03:49:29+00:00Added an answer on June 13, 2026 at 3:49 am

    Try Partition Outer Join:

    SELECT
      NVL(T.DATA, 0) DATA,
      F.MONTH,
      T.YEAR
    FROM <your_table> T
    PARTITION BY(T.YEAR)
    RIGHT JOIN (SELECT LEVEL MONTH FROM DUAL CONNECT BY LEVEL <= 12) F ON T.MONTH = F.MONTH
    

    Add your WHERE clause at the end or create a view with that definition and query against it.

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

Sidebar

Related Questions

I have a table with a year and month in different columns, and I
i have to store year and month in my table with two other columns
i have day, month, year, value columns in one table, here i need to
I have the following table that lists all awarded cups: Name: Cups Columns: Month,
I have a table with columns: MONTH , YEAR , PROJECT_ID , STATUS .
I have a employee table with columns like emp_id, firstname, lastname, month and year.
I have a table that has columns YEAR and MONTH, which are varchars, which
I have a table with four columns; Plant_Id, Year, Month and MR. I would
I have a table which contain following columns, separately: year, month, day, hour, minute,
The table columns have the data type BLOB and CLOB. What are the corresponding

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.