question

DRodrigues avatar image
DRodrigues asked

how to create variables+table (ID & DATE) - SQL

Hello, I am new to SQL/HiveQL. Could you please advise on the below.


How can I create a table with 2 variables: ORG_ID (string) and TIME_PERIOD (date) like this:


    ORG_ID | TIME_PERIOD
    C2222  | 2018-01-31
    C2222  | 2018-02-28
    C2222  | 2018-03-31
    ...
    C2222  | 2021-05-31
    C2222  | 2021-06-30
    D3333  | 2018-01-31
    D3333  | 2018-02-28
    D3333  | 2018-03-31
    ...
    D3333  | 2021-05-31
    D3333  | 2021-06-30
    W2345  | 2018-01-31
    W2345  | 2018-02-28
    W2345  | 2018-03-31
    ...
    W2345  | 2021-05-31
    W2345  | 2021-06-30


My 6 IDs: C2222, D3333, W2345, E2111, T7232, U8967

TIME_PERIOD contains the last day of each month between 2018-01-31 and 2021-06-30 (inclusive).

I don't have these variables created in the database, so first I need to create them. Can someone advise?


Thanks in advance.

Daniela

table-variable
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

0 Answers

· Write an Answer

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.