9

SQL Query question; oldest single row from one table per row in second table

view full story
linux-howto

http://hardforum.com – Hi folks, I'm something of an SQL noob. That said, I have two tables: Code: Procedures Procid, procdb, patid, patdb, pldate, chart_status, provid, provdb Primary key( procid, procdb ) Foreign key( patid, patdb ) references patients Patients patid, patdb, status Primary key( patid, patdb ) I'm wanting to select the single oldest record from procedures ( based on chart_status ) for each active patient ( status=1 ). So if I have 45,000 patients, I should get 45,000 rows returned in the results. I have this working with a cursor, but I can't help but feel there's a bette (Hardware)