[ale] Organizing data / SQL Question

Chris Fowler cfowler at outpostsentinel.com
Wed Apr 28 10:56:49 EDT 2004


I've created a query that gives me all alarms that I've not notified 
anyone on.

select alarm.alarm_id as alarm_id , notification.alarm_id as
notification_id,
location.location_id as location_id ,
escalation.escalation_id from alarm
left join notification on alarm.alarm_id = notification.alarm_id
left join console on alarm.console_id = console.console_id
left join ens on console.ens_id = ens.ens_id
left join location on ens.location_id = location.location_id
left join notification_dispatch on location.location_id =
notification_dispatch.location_id
left join notification_group on
notification_dispatch.notification_group_id =
notification_group.notification_group_id
left join notification_group_escalation on
notification_group.notification_group_id =
notification_group_escalation.notification_group_id
left join escalation on notification_group_escalation.escalation_id =
escalation.escalation_id
where notification.alarm_id is NULL and alarm.status_id = 1 ;
+----------+-----------------+-------------+---------------+
| 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 |
|        7 |            NULL |           1 |             1 |
|        7 |            NULL |           1 |             2 |
|        7 |            NULL |           1 |             3 |
|        8 |            NULL |           1 |             1 |
|        8 |            NULL |           1 |             2 |
|        8 |            NULL |           1 |             3 |
|        9 |            NULL |           1 |             1 |
|        9 |            NULL |           1 |             2 |
|        9 |            NULL |           1 |             3 |
|       10 |            NULL |           1 |             1 |
|       10 |            NULL |           1 |             2 |
|       10 |            NULL |           1 |             3 |
|       11 |            NULL |           1 |             1 |
|       11 |            NULL |           1 |             2 |
|       11 |            NULL |           1 |             3 |
|       12 |            NULL |           1 |             1 |
|       12 |            NULL |           1 |             2 |
|       12 |            NULL |           1 |             3 |
+----------+-----------------+-------------+---------------+



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?

Chris






~                                         

On Wed, 2004-04-28 at 10:49, Jason Etheridge wrote:
> Fletch wrote:
> > If you want a more B&D OO, look at Python or Java; between the two I
> > probably dislike the former less.
> 
> I had never heard of B&D before.  That's funny (the acronym, though I'm 
> funny too). :D
> 
> -- Jason
> 
> _______________________________________________
> Ale mailing list
> Ale at ale.org
> http://www.ale.org/mailman/listinfo/ale



More information about the Ale mailing list