Re: Need help with SQL statement!

From: D <d_at_d>
Date: Mon, 28 Jul 2003 23:44:24 -0400
Message-ID: <vibrcus44hi06d_at_corp.supernews.com>


I would like to humbly state that, if I understand you correctly that you want the cheapest item of every order, this is no simple matter in a Totals Query. I had a similar need once where I wanted the cheapest (Min) of a product price but I also wanted all the details of that price (Order #, Date, Vendor, etc...). The problem you will have is with the Item field, by introducing this third field you will wind up getting all the items. I do not claim to be an expert but this is the problem that I had. I therefore decided to use a PivotChart instead and found it to be very nice and neat. I hope this helps and maybe there is someone out there that knows a better way.

Dave

"Nic" <nicpayre[junk]_at_sympatico.ca> wrote in message news:qolVa.1889$Cx4.389105_at_news20.bellglobal.com...
>
> "Alex" <sh2222_at_yahoo.com> wrote in message
> news:_5lVa.117527$TJ.6968703_at_twister.austin.rr.com...
> > I am having difficulty writing a SQL statement and I was wondering if
one
> of
> > you gurus could help me. I have a table that has three fields:
InvoiceID,
> > Item, ItemPrice. Each InvoiceID is associated with one or more Items. I
am
> > trying to write a SQL statement that returns the record (all three
fields)
> > for the least expensive item for each invoice (so the total number of
> > records returned will be equal to the total number of unique Invoice
IDs.
> > How would I write this SQL statement?
> >
> What you need is a group function...i let you guess wich one it is.
> >
> >
> > Thank you,
> >
> >
> >
> > Alex
> >
> >
>
>
Received on Tue Jul 29 2003 - 05:44:24 CEST

Original text of this message