[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[ale] Organizing data / SQL Question
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 ??
-- Jason