[ale] Organizing data / SQL Question

Chris Fowler cfowler at outpostsentinel.com
Wed Apr 28 11:11:36 EDT 2004


On Wed, 2004-04-28 at 11:06, Jason Etheridge wrote:
> Chris Fowler wrote:
> > +----------+-----------------+-------------+---------------+
> > | alarm_id | notification_id | location_id | escalation_id |
> > +----------+-----------------+-------------+---------------+
> > |        5 |            NULL |           1 |             1 |
> > |        5 |            NULL |           1 |             2 |
> > |        5 |            NULL |           1 |             3 |
> > |        6 |            NULL |           1 |             1 |
> > |        6 |            NULL |           1 |             2 |
> > |        6 |            NULL |           1 |             3 |
> <snip>
> > There are 3 rows for alarm 4 and I really only need to notify the users
> > in the first escalation_id.  Is there a SQL function that will only give
> > me the first row of each alarm since here I do not need the other 2?
> 
> Hrmm.. what is enforcing how these rows are ordered?  Just an 
> implementation quirk?  Is the escalation_id you want always going to be 
> smallest value?  SELECT MIN(escalation_id) FROM ... WHERE ... GROUP BY 
> alarm_id ??

No it will be the first one that pops up.  
> 
> -- Jason



More information about the Ale mailing list