用sql语句进行多表连接查询出现重复数据 100
selectpdtl.PayGUID,payR.PayAccount,payR.PayBank,p.ProjName,u.UserName,u.WorkNo,u.Card...
select
pdtl.PayGUID,
payR.PayAccount,
payR.PayBank,
p.ProjName ,
u.UserName ,
u.WorkNo ,
u.CardNumber ,
u.ContactMobile ,
u.CompanyEmail ,
CAST(ROUND(pdtl.PayPrincipal / 10000.00, 2) AS DECIMAL(18, 2)) AS PayPrincipal ,
'1:' + CAST(pdtl.OrderRate AS VARCHAR(10)) + '倍' AS ConfirmRate ,
CAST(ROUND(( pdtl.PayPrincipal)
/ 10000.00, 2) AS DECIMAL(18, 2))* (pdtl.OrderRate+1) AS AmountTotal
from gt_PayDtl pdtl
INNER JOIN dbo.gt_Pay pay ON pdtl.PayGUID = pay.PayGUID
INNER JOIN dbo.p_Project p ON pay.ProjGUID = p.p_projectId
INNER JOIN dbo.gt_User u ON pdtl.UserGUID = u.UserGUID
left join dbo.gt_PayRecord payR on payR.PayGUID=pdtl.PayGUID
where pdtl.PayPrincipal>0
我一inner join dbo.gt_PayRecord payR on payR.PayGUID=pdtl.PayGUID 就出现几万行数据,该怎么改呢? 展开
pdtl.PayGUID,
payR.PayAccount,
payR.PayBank,
p.ProjName ,
u.UserName ,
u.WorkNo ,
u.CardNumber ,
u.ContactMobile ,
u.CompanyEmail ,
CAST(ROUND(pdtl.PayPrincipal / 10000.00, 2) AS DECIMAL(18, 2)) AS PayPrincipal ,
'1:' + CAST(pdtl.OrderRate AS VARCHAR(10)) + '倍' AS ConfirmRate ,
CAST(ROUND(( pdtl.PayPrincipal)
/ 10000.00, 2) AS DECIMAL(18, 2))* (pdtl.OrderRate+1) AS AmountTotal
from gt_PayDtl pdtl
INNER JOIN dbo.gt_Pay pay ON pdtl.PayGUID = pay.PayGUID
INNER JOIN dbo.p_Project p ON pay.ProjGUID = p.p_projectId
INNER JOIN dbo.gt_User u ON pdtl.UserGUID = u.UserGUID
left join dbo.gt_PayRecord payR on payR.PayGUID=pdtl.PayGUID
where pdtl.PayPrincipal>0
我一inner join dbo.gt_PayRecord payR on payR.PayGUID=pdtl.PayGUID 就出现几万行数据,该怎么改呢? 展开
6个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询