Reputation: 31
I am working in a test and they said in the correction that this can't be executed, can you pleased explain to me why ? Thanks in advance
SELECT SDATE, DISTINCT S_CID
FROM SESSIONS
ORDER BY S_CID, SDATE
to explain more:
S_CID
: is a foreign key in the table SESSIONS
, it is the key of the course.SDATE
: is the date of the sessionUpvotes: 0
Views: 115
Reputation: 1269513
Your distinct
is in the wrong place:
SELECT DISTINCT SDATE, S_CID
FROM SESSIONS
ORDER BY S_CID, SDATE;
I think this will do what you want -- get one date and s_cid
value with no duplicates.
Remember: SELECT DISTINCT
is a statement in SQL. The DISTINCT
(in this case) only modifies SELECT
. It does not apply to individual columns, but to all the columns in the SELECT
list.
Upvotes: 3