开发者

Select everything, based on distinct USER ID in Oracle

I am trying to select * from an oracle table, but only where user_id are unique.

i tried this:

select distinct user_id from users; -- which worked

i want to display EVERYTH开发者_如何学编程ING, so when i put:

select distinct user_id, * from users; -- i get a syntax error

how can i accomplish his?


select distinct user_id, users.* from users; 


select * from users where users.primary_key IN 
  (select primary_key FROM users GROUP BY user_id HAVING count(*) = 1)

This will only select records that do not share user_ids with other rows.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜