Home » SQL & PL/SQL » SQL & PL/SQL » help needed
help needed [message #186630] Tue, 08 August 2006 15:41 Go to next message
Jolanda
Messages: 68
Registered: September 2004
Member
Hello you all,

I want to select records which just occur once in a table and which have a number_id = 0 as max.

table_x

id name hobby number
1 me footbal 0

2 he swim 0

2 he dance 1

3 she sleep 0
3 she fitness 1
3 she movies 2

4 we nothing 0

as we can see, the Id's with 1 and 4 occur just once and have a max number of 0 and I need a query which can accomplish this.

can anyone help me out?

thanks

ps: i have asked this question in other forums, but unfortenately haven't had a satisfying answer...

hope someone here can help me out...
Re: help needed [message #186635 is a reply to message #186630] Tue, 08 August 2006 16:02 Go to previous messageGo to next message
Littlefoot
Messages: 20891
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
SELECT id
FROM table_name
GROUP BY id
HAVING COUNT(*) = 1
  AND MAX(number) = 0
Re: help needed [message #186638 is a reply to message #186635] Tue, 08 August 2006 16:25 Go to previous messageGo to next message
Jolanda
Messages: 68
Registered: September 2004
Member
Hi Littlefoot,

Thank you for your answer (again Smile ).

It gives back the records which I need, but I can't process them in a cursor. Is there a way to rewrite this so it can be process within a cursor?

Thanks
Re: help needed [message #186639 is a reply to message #186638] Tue, 08 August 2006 16:32 Go to previous message
Jolanda
Messages: 68
Registered: September 2004
Member
sorryyyyy you all,

problem solved already!

Thankss
Previous Topic: Exception handling
Next Topic: Transfer users (merged)
Goto Forum:
  


Current Time: Sun Dec 04 10:55:26 CST 2016

Total time taken to generate the page: 0.08121 seconds