I'm using Crystal SQL Designer 8.0. I am able to paste my sql by going to File / New / Enter SQL Statement Directly.
I moved the bottom select statement to the top and it is now showing all the data in Crystal Designer which matches the records as if I were to run the query in Query Analyzer.
However, I'm still not able to see all the records in the report.
I tried pasting the sql into an ADO connection and that is giving me a "Timeout Expired" message after a few seconds.
I also tried modifying the sql directly in the report after I made a query that calls one of the table that i'm using and selecting some of the fields that I need. After the report is generated, I go to SHOW SQL QUERY and deletes the current query and paste my original query with the UNION statement. By doing this, I get the following message "The column prefix "VP_TIMESHEETPUNCH" does not match with a table name or alias name used in the query.
Here is the query that I'm trying to use:
select TS.workrulename,TS.laborlevelname4,L.description,TS.personnum,TS.personfullname,TS.eventdate,datepart(q,TS.eventdate) as 'eventqtr', datepart(yy,TS.eventdate) as 'eventyear', 0 as 'breaktime', sum(TS.timeinseconds) as 'lengthOfShift',
0 as 'InCompliance'
from vp_timesheetpunch as TS inner join laborlevelentry as L
on TS.laborlevelname4 = L.name
group by
TS.workrulename,TS.laborlevelname4,L.description,TS.personnum,TS.personfullname,TS.eventdate,datepart(q,TS.eventdate), datepart(yy,TS.eventdate)
having count(TS.personnum) = 1 and
sum(TS.timeinseconds) >= 21601
UNION
select t1.workrulename,t1.laborlevelname4,t1.description,t1.personnum, t1.personfullname, cast(t1.eventdate as datetime) as 'eventdate', datepart(q,t1.eventdate) as 'eventqtr', datepart(yy,t1.eventdate) as 'eventyear', datediff(mi,t1.outpunchdtm, t2.inpunchdtm) as 'breaktime', (datediff(ss,t1.inpunchdtm,t2.outpunchdtm) - datediff(ss,t1.outpunchdtm, t2.inpunchdtm)) as 'lengthOfShift',(case when datediff(mi,t1.outpunchdtm, t2.inpunchdtm) >= 30 then 1 else 0 end) as 'InCompliance'
from
(select top 100 percent workrulename,laborlevelname4, description, personnum, personfullname, eventdate, startdtm, enddtm, inpunchdtm, outpunchdtm, startreason
from vp_timesheetpunch as A inner join laborlevelentry as L on A.laborlevelname4 = L.name
where exists
(select personnum, personfullname, eventdate, startreason
from vp_timesheetpunch b
where
b.personnum = a.personnum and
startreason like 'break:Meal%'
)
order by personfullname, inpunchdtm
) as t1
inner join
(
select top 100 percent workrulename,laborlevelname4,personnum, personfullname, eventdate, startdtm, enddtm, inpunchdtm, outpunchdtm, startreason
from vp_timesheetpunch as A
where exists
(select personnum, personfullname, eventdate, startreason
from vp_timesheetpunch
where
personnum = a.personnum and
startreason like 'break:Meal%'
group by
personnum, personfullname, eventdate, startreason
)
order by personfullname, inpunchdtm desc
) as t2
on t1.personnum = t2.personnum
and t1.eventdate = t2.eventdate
and t2.inpunchdtm >= t1.outpunchdtm
where
datediff(mi,t1.outpunchdtm, t2.inpunchdtm) < 60
group by
t1.workrulename,t1.laborlevelname4, t1.description, t1.personnum, t1.personfullname, t1.eventdate, t1.inpunchdtm, t1.outpunchdtm, t1.startreason, t2.inpunchdtm, t2.outpunchdtm, t2.startreason
having
(datediff(ss,t1.inpunchdtm,t2.outpunchdtm) - datediff(ss,t1.outpunchdtm, t2.inpunchdtm)) > 21601