I have the below query where i return all users, but they are users with the same TYPEUSER
select * from utilisateur ut where ut.TYPEUSER != 'classe' AND ut.TYPEUSER != 'user'
I tried with the below query to get unique users by TYPEUSER, but it returns this error ORA-00936: missing expression
select distinct ut.PRENOMUSER, * from utilisateur ut where ut.TYPEUSER != 'classe' AND ut.TYPEUSER != 'user'
Oracle allows select *
. But if you select other columns, you need to qualify the *
. So:
select distinct ut.PRENOMUSER, ut.*
from utilisateur ut
where ut.TYPEUSER <> 'classe' AND ut.TYPEUSER <> 'user';
This is just one of the syntactic weirdnesses of Oracle. Another is that as
is not permitted in the FROM
clause (I wouldn't use it anyway). I think it is because Oracle is the oldest database, long pre-dating the SQL standard.
You dont even need ut.PRENOMUSER
in select clause. it is irrelevant.
Use following query:
select distinct ut.*
from utilisateur ut
where ut.TYPEUSER <> 'classe' AND ut.TYPEUSER <> 'user';
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.