Click here to Skip to main content
15,895,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
SQL
select m.wagerefcode v,empname e,recorddate d,sum(finalamount) a,
(select isnull(vch_no,'') from ERP1314..SH_VCH_M_EXP where PN_VOUCHER = M.WageRefCode) as BMCM,
(select Convert(varchar,vch_Date,106) from ERP1314..SH_VCH_M_EXP where PN_VOUCHER = M.WageRefCode) as BMCMDate,
(select isnull(vch_no,'') from ERP1314..SH_VCH_M where PN_VOUCHER = M.WageRefCode) as BPCP,
(select Convert(varchar,vch_Date,106) from ERP1314..SH_VCH_M where PN_VOUCHER = M.WageRefCode) as BPCPDate
 from pr_dailywages_m m,pr_dailywages_d d,employee_m emp where emp.empid=m.empid and d.wagerefcode=m.wagerefcode and m.mainlocid in (2,11)
 and recorddate between '1/Sep/201' and '03/Oct/2013'  and m.cmp_id = 'SZS' Group by EmpName, m.WageRefCode,recorddate order by recorddate
Posted
Updated 3-Oct-13 2:58am
v2

1 solution

i think you need to take top(1) from your below query or take Max or Min from below query

SQL
(select isnull(vch_no,'') from ERP1314..SH_VCH_M_EXP where PN_VOUCHER = M.WageRefCode) as BMCM,
SQL
(select Convert(varchar,vch_Date,106) from ERP1314..SH_VCH_M_EXP where PN_VOUCHER = M.WageRefCode) as BMCMDate,

SQL
(select isnull(vch_no,'') from ERP1314..SH_VCH_M where PN_VOUCHER = M.WageRefCode) as BPCP,
SQL
(select Convert(varchar,vch_Date,106) from ERP1314..SH_VCH_M where PN_VOUCHER = M.WageRefCode) as BPCPDate


it should be something like this

SQL
(select TOP(1)isnull(vch_no,'') from ERP1314..SH_VCH_M_EXP where PN_VOUCHER = M.WageRefCode) as BMCM,

SQL
(select TOP(1)Convert(varchar,vch_Date,106) from ERP1314..SH_VCH_M_EXP where PN_VOUCHER = M.WageRefCode) as BMCMDate,

SQL
(select TOP(1)isnull(vch_no,'') from ERP1314..SH_VCH_M where PN_VOUCHER = M.WageRefCode) as BPCP,

SQL
(select TOP(1)Convert(varchar,vch_Date,106) from ERP1314..SH_VCH_M where PN_VOUCHER = M.WageRefCode) as BPCPDate
 
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