Caleeco
Well-known Member
- Joined
- Jan 9, 2016
- Messages
- 980
- Office Version
- 2010
- Platform
- Windows
Hello,
I am struggling with a SQL statement (im fairly new to it). I have a table that records a seating plan in an office. So each record represents a day, and each column represents a seat. Users then populate the table to book seats on certain days.
So I wish to return a list
I have tried the following, but feel there may be a more elegant solution? Also I need to add a WHERE <> Null clause somewhere as I have a NULL value returned in my table.
Any help is appreciated
Many Thanks
Caleeco
I am struggling with a SQL statement (im fairly new to it). I have a table that records a seating plan in an office. So each record represents a day, and each column represents a seat. Users then populate the table to book seats on certain days.
PK_Date | Seat1 | Seat2 | Seat3 | Seat4 | Seat5 |
---|---|---|---|---|---|
25/10/2020 | |||||
26/10/2020 | HS | PH | |||
27/10/2020 | PH | YT | |||
28/10/2020 | KK | ||||
29/10/2020 | EM |
So I wish to return a list
Names |
---|
HS |
PH |
KK |
YT |
EM |
SQL:
SELECT DISTINCT * FROM (
SELECT S1
FROM SeatingT
union
SELECT S2
FROM SeatingT
union
SELECT S3
FROM SeatingT
union
SELECT S4
FROM SeatingT
union
SELECT S5
FROM SeatingT);
I have tried the following, but feel there may be a more elegant solution? Also I need to add a WHERE <> Null clause somewhere as I have a NULL value returned in my table.
Any help is appreciated
Many Thanks
Caleeco
Last edited: