Quote:
Originally Posted by
hcclnoodles
...
I have a view which is working fine, but i have been told that i need to make sure the resulting output excludes all rows with nic_status equal to the string "removed".
...
The answer is: "It depends".
You are doing two things in your view -
(a) determining the maximum
datetimestamp for each tuple (
serial, nic_name) of the
network table.
(b) Fetching a few more columns for the tuple (
serial, nic_name, max_datetimestamp),
nic_status included.
Now, do you want to consider status = "removed" while finding out the max of datetimestamp ?
If no, then the predicate simply gets added to the subquery.
If yes, then the predicate goes in the outer query.
Again, in the latter case, what do you want to do if the max of
datetimestamp is for a record that has nic_status = "removed" ? The inner query would fetch that, but it would be discarded by the outer query. Do you want no rows returned for that tuple, or do you want to check for the max
datetimestamp of records with nic_status != "removed" in the first place itself ?
HTH,
tyler_durden