× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



I have a master file supported by a transactions file; the transactions file includes an event code (possibly duplicated) and timestamp.

I'm trying to develop an embedded SQL statement to join the master and transaction files and to return a record set consisting of one row per master record with the master record key, the /last/ event (based on the timestamp), and the /last/ timestamp.

The timestamp is not in the master file, of course.

I have something like this (which provides duplicate records):

select master, event, timestamp from master
left outer join detail on master_key=detail_key
order by master_key,timestamp desc

Here are my problems: DISTINCT appears to work on the whole row and not on a selected columns; and I guess FETCH 1 ROW doesn't work in interactive SQL (or, more likely, /I/ don't know how to use specify "fetch 1 row per order number").

I can solve the problem by eliminating the JOIN and doing a READE against a logical over the transactions file with a descending key on the timestamp; this provides pretty good performance for this interactive application. Or, if I can figure out how to get one record per master/detail record set, I can figure out how to get the last detail.

My SQL thinking is still developing, and I just can't figure out how to tackle this one. I'd appreciate any suggestions!

Thanks,
IRG

_________________________________________________________________
What are the 5 hot job markets for 2004? Click here to find out. http://msn.careerbuilder.com/Custom/MSN/CareerAdvice/WPI_WhereWillWeFindJobsIn2004.htm?siteid=CBMSN3006&sc_extcmp=JS_wi08_dec03_hotmail1



As an Amazon Associate we earn from qualifying purchases.

This thread ...

Follow-Ups:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.