Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

Announcements
Modernize Your QlikView Deployment webinar, Nov. 3rd. REGISTER
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Creator II
Creator II

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
Highlighted
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.

Highlighted
Master III
Master III

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

Highlighted
Creator II
Creator II

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

Highlighted
Creator II
Creator II

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

how to do that ?

Highlighted
Creator II
Creator II

script.png

Highlighted
Creator II
Creator II

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

Highlighted
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';


Highlighted
Creator II
Creator II

please refer the following image script.png

Highlighted
Creator II
Creator II

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