问题描述
薪水支付-支付金额,用户ID,月,年,薪水支付,奇克诺,已完成支付的注释包含记录
所有emp的tbl_users-userid,empname,emailid,address-conain记录
我有2个下拉月份,年份
假设用户从下拉菜单中选择jan 2012,然后
它在这些人的gridview中显示记录
薪水待定且已支付薪水的emp
我无法通过sql查询任何人,请plz帮助我
我尝试过了
salarypayment--paymentid,userid,month,year,salarypaid,chequeno,comment-contain record whose payment has done
tbl_users-userid,empname,emailid,address-conain record of all emp
i have 2 dropdown month,year
suppose user select jan 2012 from dropdown then
it show record in gridview of those
emp whose salary is pending and whose salary is already paid
i am not able to fire sql query anyone plz help me
i tried this
select u.UserID,u.FirstName+' '+u.LastName[name],st.SalaryPaid[SalaryPaid],dbo.ufn_MAFormatDate(st.PaymentDate)PaymentDate,st.ChequeNo[ChequeNo],st.Comments[Comments],pt.Desc_[PaymentType],st.PaymentID
from tbl_Users u
left outer join tbl_SalaryPaymentDetails st on st.UserID=u.UserID
left outer join TBL_PaymentType pt on pt.PaymentTypeID=st.PaymentType
where u.UserID in(select UserID from tbl_SalaryPaymentDetails where month =1 and year=113)
推荐答案
SELECT U.FIRSTNAME + ' ' + U.LASTNAME AS NAME,
US.SALARYPAID AS SALARY,
US.PAYMENTDATE AS DATE,
US.COMMENTS AS COMMENTS ,
US.PAYMENTTYPE AS PAYMENT_TYPE
FROM TBL_USERS U
LEFT OUTER JOIN TBL_SALARYPAYMENTDETAILS US
ON US.USERID = U.USERID AND US.YEAR = 2012 ;
如果要显示特定月份,则在末尾添加"ADD US.MONTH = 2".
if you want to show for the specific month than add ''ADD US.MONTH = 2'' at the end.
这篇关于sql查询疑问帮帮我的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!