QlikView App Dev

Discussion Board for collaboration related to QlikView App Development.

Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More

Who Me Too'd this topic

sagar_vij99
Creator
Creator

SQL Query not running with sub query

Hi All,

 

I am fetching some data from server (view is created on server) in my .qvw file. When i simply pull data using select statement it gives me the data.

But i modified the query inorder to pull data faster but now the query is not getting executed. Table with column gets created but no data is fetched. Can somebody help me here..?

Below is the query i am using:

OLEDB CONNECT32 TO [Provider=SQLOLEDB.1;Integrated Security=SSPI;Persist Security Info=False;Initial Catalog=ACVSBIRS;Data Source=Ewrdb1464;Use Procedure for Prepare=1;Auto Translate=True;Packet Size=4096;Workstation ID=R01-E7C6D9DE81;Use Encryption for Data=False;Tag with column collation when possible=False];
Ccure_SQL:

 

SQL Select C.*, case when C.Att<=5 then '0-5 Days'
when C.Att>=6 and C.Att<=10 then '6-10 Days'
when C.Att>=11 and C.Att<=15 then '11-15 Days'
else '>15 Days'
end as Bracket

from

(select A.*,B.Att
from

(
SELECT cast(SiteLocalTime as date) as date1
,PrimaryObjectName
,[SecondaryPartitionName]
,[CardNo]
,[FacilityNo]
,[Personnel_Type]
,[Home_Location_]
,[LastName]
,[FirstName],
count(distinct [CardNo]) as D_Att,
month(cast(SiteLocalTime as date)) as Month_Field
FROM [ACVSBIRS].[dbo].[vQJournal]
where PrimaryObjectName = 'Vij, Sagar,' --and month(cast(SiteLocalTime as date)) = 11
group by
cast(SiteLocalTime as date)
,PrimaryObjectName
,[SecondaryPartitionName]
,[CardNo]
,[FacilityNo]
,[Personnel_Type]
,[Home_Location_]
,[LastName]
,[FirstName],
month(cast(SiteLocalTime as date))
)as A

left join

(select count(D_Att) as Att , [CardNo],Month_Field,PrimaryObjectName
from
(
SELECT cast(SiteLocalTime as date) as date1
,PrimaryObjectName
,[CardNo]
, count(distinct [CardNo]) as D_Att,
month(cast(SiteLocalTime as date)) as Month_Field
FROM [ACVSBIRS].[dbo].[vQJournal]
--where PrimaryObjectName = 'Vij, Sagar,'-- and month(cast(SiteLocalTime as date)) = 11
group by
cast(SiteLocalTime as date)
,[CardNo],
month(cast(SiteLocalTime as date)),
PrimaryObjectName
)x
group by
[CardNo],
Month_Field,
PrimaryObjectName
) as B

on A.[CardNo] = B.[CardNo] and A.Month_Field = B.Month_Field and A.PrimaryObjectName = B.PrimaryObjectName
) as C;


Exit Script

Labels (3)
Who Me Too'd this topic