Replicate a field based on unjoined tables

Posted on 2008-11-18
Last Modified: 2012-05-05
I have two tables (table a) has data like this


(table b) has data like this


I need a query that gives me the following results

Year  |  Month
2008     Jan
2008     Feb
2008     Mar
2009     Jan
2009     Feb
2009     Mar

I'm OK on parsing the date from table A  and grouping the years in table B, but I'm not sure how to join them.  The idea is that when a 2010 record is added (in the beginning of 2010) I get...

2008  Jan
2008  Feb
2008  Mar
2009  Jan
2009  Feb
2009  Mar
2010 Jan
2010 Feb
2010 Mar

and so on.. thanks in advance
Question by:jclemo
    1 Comment
    LVL 14

    Accepted Solution


    select * from
    (select mnt from TableA) as TabA,(select DISTINCT YEAR(dt) as dtYear from TableB) as TabB

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    Join & Write a Comment

    Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
    Using SQL Scripts we can save all the SQL queries as files that we use very frequently on our database later point of time. This is one of the feature present under SQL Workshop in Oracle Application Express.
    Video by: Steve
    Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    745 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

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now