Click here to Skip to main content
15,892,746 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
Hi,
I have a Sql Query Using Union
select Users.UserId,Users.EmpNo,(Users.FirstName+''+Users.LastName) As FullName,EmpPayments.SalBasic,EmpPayments.SalCon,EmpPayments.SalDA,EmpPayments.SalHRA from Users  join EmpPayments on Users.UserId=EmpPayments.UserId where Users.UserId=24 and MainContractorSw='Y' and EmpPayments.MonthId=8 and EmpPayments.YearId=2010 
Union 
select Users.UserId,Users.EmpNo,(Users.FirstName+''+Users.LastName) As FullName,EmpPayments.SalBasic,EmpPayments.SalCon,EmpPayments.SalDA,EmpPayments.SalHRA from Users join EmpPayments on Users.UserId=EmpPayments.UserId where Users.MainContractorSw='N' EmpPayments.MonthId=8 and EmpPayments.YearId=2010 and Users.MainContractorId=24

Here the First Query will give the result of Contractor
and the second query will give the result of SubContractors whose contractor is the Contractor we get from First Query.
I have to Use this query in Crystal Report.
Now,How can i give the condition in Report Section because i have to use the 2 queries Conditions..
I have tried a lot Used 'AND' condition it is not retrieving anything and used 'OR' But the Results are repeating ......
Posted
Updated 18-Nov-10 21:30pm
v2

1 solution

Select Distinct (...)

Then use a nested query to retrieve the inner fields.

Join the inner query with the outer on EmpPayments ID.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900