Jump to content

group by with where clause


Recommended Posts

My Oracle table columns are: message_id, status, start_time

 

There is no primary key. There are multiple rows for each message_id.

 

I would like to be able to select records where the record that has the mininum start_time value for records grouped by message_id has a status value of 'PC'

 

Thanks!

 

 

 

 

 

 

Link to comment
https://forums.phpfreaks.com/topic/257659-group-by-with-where-clause/
Share on other sites

I don't think that is going to work.

I only want the records where the min(start_time) for records grouped by message_id has a status value of 'PC'

I was able to get a result with the following. Is there a better way to do this?

 

select message_id from table where start_time in

(select min(start_time) from table group by message_id)

and status = 'PC'

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.