alain lino
alain lino

Reputation: 31

SQL query can't be executed

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:

Upvotes: 0

Views: 115

Answers (1)

Gordon Linoff
Gordon Linoff

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

Related Questions