Monday, 20 May 2013

SQL Select, selecting a row off of a column condition

SQL Select, selecting a row off of a column condition

Division Department Dept. Head 1 1 Mr. Anon
2 1 NULL 3 1 NULL
1 2 NULL 2 2 NULL 3 2 NULL
I am trying to write a query that will select rows based on conditions for the 3rd column (Dept. Head). If there is a row in the department head that is not null (Mr. Anon) select that row. If there are no rows in the department head with a non null value, select any row.
So out of the two groups i have in the above table, i want to select only one row from each.

No comments:

Post a Comment