Subject Re: [firebird-support] sql puzzle
Author Arno Brinkman
Hi,

> Can somebody help me with this. I want to form a sql statement that
> could get the price of each item from the lastest invoice. Here are
> some of the table definition. the ITEM table has (itemid, itemname),
> INVOICE table has (invno, invdate), INVOICEDETAILS table(invno, itemid,
> price). This definition table is not the complete one I just list the
> important one. Iam having a problem contructing it, Iam trying to avoid
> using Stored Procedures or Views as much as possible.

Something like this :

SELECT
id.itemid,
item.itemname,
id.price
FROM
INVOICE i
JOIN INVOICEDETAILS id ON (id.invo = i.invo)
JOIN ITEM item ON (item.itemid = id.itemid)
WHERE
i.invdate = (SELECT MAX(i2.invdate) FROM INVOICE i2)


Regards,
Arno Brinkman
ABVisie

-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Firebird links :
http://www.firebirdsql.com
http://www.firebirdsql.info
http://www.fingerbird.de/
http://www.comunidade-firebird.org/


Nederlandse firebird nieuwsgroep :
news://80.126.130.81