Quantcast
Channel: SCN : All Content - All Communities
Viewing all articles
Browse latest Browse all 3323

Nested Select Statement

$
0
0

Hi All

 

I am trying to amend a query used as a base for a crystal report.

and trying to a add a quantity (InQty from OINM) field using a nested select statement. I know TOP does not work with HANA.

 

I need the quantity of the item per last purchasing document and last sales document..separately.

so i have done the below.

 

 

SELECT CAST(MAX(T0."DocDate") AS date) AS "Date", T0."ItemCode", T5."ItemName", T5."ItmsGrpCod", T6."ItmsGrpNam" AS "Item Group",

T0."Warehouse" AS "Whse", SUM(T0."InQty") - SUM(T0."OutQty") AS "QTY", T1."Price", T1."PriceList", MIN(T0."TransType") AS "TransType",

CAST(MAX(t4."LastsoldDate") AS date) AS "Last Sales Date",

CAST(MAX(t3."LastDate") AS date) AS "Last Purchase Date",

--MAX(T0."InQty"), MAX(T0."OutQty")

 

 

 

(SELECT "InQty"

FROM

(SELECT S0."InQty", Rank() OVER (PARTITION BY S0."ItemCode" ORDER BY S0."DocDate" DESC ) AS Rank

FROM OINM S0

Where S0."ItemCode" = T0."ItemCode" and (S0."TransType" = 20)

GROUP BY S0."ItemCode", S0."InQty", S0."DocDate"

)

WHERE Rank < 1

GROUP BY "InQty"

) as "IN QTY"                       

                       

FROM OINM T0 INNER JOIN ITM1 T1 ON T0."ItemCode" = T1."ItemCode"

 

The query finally ran, but that field is blank.

 

Please help ,

 

Regards,


Viewing all articles
Browse latest Browse all 3323

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>