Re: THE SQL CHALLENGE!

From: Stephen Lappin <100045.167_at_CompuServe.COM>
Date: 4 Sep 1994 16:59:40 GMT
Message-ID: <34cuds$nhp$3_at_mhadg.inhouse.compuserve.com>


In article <3478u6$lit_at_charm.magnus.acs.ohio-state.edu>,

        phart_at_magnus.acs.ohio-state.edu (Patrick S Hart) writes:

> Hi Folks!
 

> I have been trying, to no avail, to solve the below problem
 with only one
> pass at the data. I was curious to know if anyone can solve
this:

> Table Definition:

> I want to select the *last* recorded Inventory for a given
date.

Try using a nested sub-query thus

   SELECT * FROM table t1
   WHERE LastInvDate = (SELECT MAX(LastInvDate) FROM table t2

                        WHERE t2.StockNumber = t1.StockNumber)

Slainte mhath
Stephen Received on Sun Sep 04 1994 - 18:59:40 CEST

Original text of this message