By using db<>fiddle, you agree to license everything you submit by Creative Commons CC0.
13 rows affected
| emp_id | name |
|---|---|
| 1 | George |
| 2 | Josef |
| 3 | Bill |
| 4 | Jack |
| 5 | Toti |
| TICKET | EMP_ID | RANK_OF_TICKET |
|---|---|---|
| 001 | 1 | 1 |
| 002 | 1 | 2 |
| 003 | 1 | 3 |
| 004 | 2 | 1 |
| 005 | 3 | 1 |
| 006 | 3 | 2 |
| 007 | 3 | 3 |
| 008 | 3 | 4 |
| emp_id | name | first_ticket | 2nd_ticket | 3rd_ticket | 4th_ticket | 5th_ticket |
|---|---|---|---|---|---|---|
| 1 | George | 001 | 002 | 003 | null | null |
| 2 | Josef | 004 | null | null | null | null |
| 3 | Bill | 005 | 006 | 007 | 008 | null |
| 4 | Jack | null | null | null | null | null |
| 5 | Toti | null | null | null | null | null |