🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Thread View: borland.public.interbase.sql
2 messages
2 total messages Started by Henry Olive Sat, 23 Nov 2002 18:40
SQL - Calc.Field
#11351
Author: Henry Olive
Date: Sat, 23 Nov 2002 18:40
28 lines
1600 bytes
IB6, D6

Detail Table : Trs Means ( Transfer from last year )
PK=Recnum,LineNum

PARTNO    TRSQty   BUYQty   SELLQty
--------------------------------------------
AAA            2                0               0
BBB             0                2               0
AAA            0                0               1


Part Table :  PK=PartNo
PARTNO        COSTPRICE
------------------------------
AAA                   100.00
BBB                    250.00

I need Current Inventory Value.
InvValue:=600.00.-
( which is ,  1 * AAA (100.00)   +  2 * BBB( 250.00) )

Something like below.
SELECT SUM(D.TRSQty + D.BUYOty - D.SELLQty)*P.COSTPRICE
FROM DETAIL D, PARTS P
WHERE(P.PARTNO = D.PARTNO)

Thank you.
Re: SQL - Calc.Field
#11358
Author: Harun Bolat
Date: Sun, 24 Nov 2002 12:41
45 lines
2116 bytes
try

SELECT SUM((TRQTY + BUYQTY - SELLQTY) * COSTPRICE),P.PARTNO
FROM PARTS P
JOIN DETAIL D ON D.PARTNO = P.PARTNO
GROUP BY P.PARTNO

"Henry Olive" <zed@zedltd.com> wrote in message
news:3ddfcb72@newsgroups.borland.com...
> IB6, D6
>
> Detail Table : Trs Means ( Transfer from last year )
> PK=Recnum,LineNum
>
> PARTNO    TRSQty   BUYQty   SELLQty
> --------------------------------------------
> AAA            2                0               0
> BBB             0                2               0
> AAA            0                0               1
>
>
> Part Table :  PK=PartNo
> PARTNO        COSTPRICE
> ------------------------------
> AAA                   100.00
> BBB                    250.00
>
> I need Current Inventory Value.
> InvValue:=600.00.-
> ( which is ,  1 * AAA (100.00)   +  2 * BBB( 250.00) )
>
> Something like below.
> SELECT SUM(D.TRSQty + D.BUYOty - D.SELLQty)*P.COSTPRICE
> FROM DETAIL D, PARTS P
> WHERE(P.PARTNO = D.PARTNO)
>
> Thank you.
>
>
>
>
>
>
>
>
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads