HELP!. Want a Cross Join with null values!

  • Hi, I have several combinations and I want to get all the possible combinations between them.

    For example (note, this is not the tables i'm working with, it's just for giving an example):

    SELECT weekday, seasons FROM weekdays CROSS JOIN seasons

    would return

    monday spring

    monday summer

    monday fall

    ...

    tuesday spring

    tuesday summer

    ...

    sunday winter

    With CROSS JOIN I get all possible combinations but always using a record from each table.

    I want to get something like this:

    null spring

    null summer

    ...

    monday null

    monday spring

    monday summer

    ...

    tuesday null

    tuesday spring

    ...

    sunday winter

     

    Please help me, it's urgent

  • Select * from

    (

    Select null

    union all

    Select season from dbo.saisons

    ) dtNulls

    cross join days

Viewing 2 posts - 1 through 1 (of 1 total)

You must be logged in to reply to this topic. Login to reply