[AccessD] Top 3 query returns only one record

Drew Wutka DWUTKA at marlow.com
Tue May 13 15:40:38 CDT 2003


That should do it.  You're subquery was only going to give you the last
three dates of the entire table.  You need the last three dates PER
well_label.
 
Drew

-----Original Message-----
From: Kaup, Chester A [mailto:kaupca at chevrontexaco.com]
Sent: Tuesday, May 13, 2003 1:46 PM
To: ACCESSD at databaseadvisors.com
Subject: [AccessD] Top 3 query returns only one record



The following query returns only one record per well_label rather than the
last 3 like I need. I don't see the problem-been looking at it to long.
Thanks

SELECT TEST_DATE, FIELD_CODE, SAP_BORE_COMP_NUMBER, WELL_LABEL, GAS_VOL,
OIL_VOL, WATER_VOL 
FROM [TBL T15 WELL TESTS] [Drew Wutka] AS T1 
WHERE TEST_DATE IN 
(SELECT TOP 3 TEST_DATE 
FROM [TBL T15 WELL TESTS] 
[Drew Wutka] WHERE WELL_LABEL=T1.WELL_LABEL 
ORDER BY TEST_DATE DESC) 
ORDER BY WELL_LABEL ASC, TEST_DATE DESC; 

No trees were killed in the sending of this message. However a large number
of electrons were terribly inconvenienced.



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://databaseadvisors.com/pipermail/accessd/attachments/20030513/19a406cb/attachment-0001.html>


More information about the AccessD mailing list