I have what I suspect is another rookie SQL question. Sometimes I want to return the contents of all columns for a certain
Example:
In plain english What I'm after is the COLOR of the highest SEQ_NO where the ITEM_NO is 10015 and the SEG_NO is 3.
The natural SQL seems to be something like this:
Of course that doesn't work. Something about a single-row function...
This works but I suspect that there is a better way:
Am I coming at the the right way or is there a better way?
Thanks!
-Striker
Example:
Code:
ITEM_NO SEG_NO SEQ_NO COLOR
10015 3 1 Blue
10015 3 2 Red
10015 3 3 Green
The natural SQL seems to be something like this:
Code:
SELECT MAX(seq_no), color FROM table where item_no = 10015 AND seg_no = 3;
This works but I suspect that there is a better way:
Code:
SELECT color FROM table WHERE item_no = 10015 AND seg_no = 3 AND seq_no = (SELECT MAX(seq_no) FROM table WHERE item_no = 10015 and seg_no = 3);
Thanks!
-Striker