Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Finding the maximum value from a combination of fields

Status
Not open for further replies.

cjkoontz

MIS
Aug 9, 2000
102
US
I have a table that has amongst it columns the following --
* An action date,
* A transaction date, and
* A transaction time.

How would I find the last transaction date / transaction time combination for a particular action date?

I have one method where I select on the MAX (of the concatenated transaction date and transaction time columns). Is that efficient?
 
if you ensure that the "concatenation" is high-to-low, e.g. yyyy-mm-dd hh:mm:ss, then it will work

on the other hand, you could "combine" the date and time into a datetime datatype, with the same result

not sure about efficiency, you will have to run the timings or EXPLAIN PLAN using whatever tuning facilities your particular database system makes available

if you can change your table so that instead of separate date and time columns, you actually use a datetime column, then of course the efficiency will be much better, and the sql syntax will be easier too


rudy

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top