Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

How to use nested select statement in report

Hi

i want to combine two select statement in my report

following are the two nested statements

please help me in writting the corresponding code in script

These are two select statement

SQL SELECT WH.GoodsSender as NCode, SD.InvoiceNumber, SD.SalesDate,SD.ItemNumber,

SD.SaleQuantity, SD.NetValue,SD.MRPValue,SD.TaxAmount

FROM SAP_Link.dbo.Sales_DataNonETP_BIReports SD

INNER JOIN ETPEASV55.dbo.warehouse_sap_bireport WH

ON SD.CustomerId = WH.Warehouse

where SD.Doc_Type = 'ZIKE' and SD.SalesDate >= 20130101 and SD.SalesDate <= '$(currentdate)'

select warehouse,warehousedescription,goodssender from warehouse Where GoodsSender<>'NA' and GoodsSender like 'N%'

union all

select warehouse,warehousedescription,goodssender from ETPPOS.ETPEAS.dbo.Warehouse_SAP Where ISnonETP='Y'  and GoodsSender<>'NA' and GoodsSender like 'N%'

13 Replies
prma7799
Master III
Master III

Are you trying to this in SQL or in Qlikview ??

if you want to this in Qlikveiw try to take data into qvd format then do the calculation.

prma7799
Master III
Master III

Could you please explain what is the relation between to tables? which are the common column between two tables

Anonymous
Not applicable
Author

SQL SELECT WH.GoodsSender as NCode, SD.InvoiceNumber, SD.SalesDate,SD.ItemNumber,

SD.SaleQuantity, SD.NetValue,SD.MRPValue,SD.TaxAmount

FROM SAP_Link.dbo.Sales_DataNonETP_BIReports SD

INNER JOIN ETPEASV55.dbo.warehouse_sap_bireport WH

ON SD.CustomerId = WH.Warehouse

where SD.Doc_Type = 'ZIKE' and SD.SalesDate >= 20130101 and SD.SalesDate <= '$(currentdate)'

i Want this condition with the above one

where warehouse in(select distinct warehouse from warehouse_sap where goadssender  like '%N'

warehouse and goads sender are the common columns between two feilds

Anonymous
Not applicable
Author

I want to actually insert the second condition with the first one

how to do that ?

Anonymous
Not applicable
Author

script.png

Anonymous
Not applicable
Author

now i want to add this condition also where warehouse in (select distinct warehouse from warehouse_sap where goadssender like '%n'

prma7799
Master III
Master III

If ETPEASV55.dbo.werehouse _sap_bireport  same like warehouse_sap this table then you can try like below


where  wildmatch(goadssender,'n*' )



or goads sender are the common columns between two table then


from ETPEASV55.dbo.werehouse _sap_bireport WH

left join

warehouse_sap WS

on  WH.goadssender = WS.goadssender

where WS.goadssender like '%n';


Anonymous
Not applicable
Author

please refer the following image script.png

Anonymous
Not applicable
Author

these are two tables

SAP_Link.dbo.Sales_DataNonETP_BIReports SD and

ETPEASV55.dbo.warehouse_sap_bireport WH

goodssender is the common feild in both