子查询相关问题

子查询相关问题

问题描述:

SELECT CD.FirstName+''''+CD.MiddleName+'' ''+CD.LastName as Name,CD.MobileNumber,CD.email,CD.RegisterDate,BD.DC_Bill FROM Customer_Details CD LEFT JOIN (SELECT CustomerID,SUM(DC_Bill) AS [DC_BILL] FROM Bill_Details GROUP BY CustomerID) BD ON CD.CustomerID = BD.CustomerID



我已经有了上面的查询.
现在如何在日期范围内选择DC_Bill,然后汇总值?

现在,我可以使用上述查询获得所有DC_Bill详细信息,但我只想获取日期范围内的某些选定值.

请帮我解决这些问题.
在此先感谢



I already have the above query.
now how do i select DC_Bill within a date range and then summarize the value?

Now i can have all the DC_Bill details using these above query but i want to get only some selected value within a date range.

Please help me to solve these.
Thanks in advance

尝试一下
SELECT
    CD.FirstName+''+CD.MiddleName+' '+CD.LastName as Name
    ,CD.MobileNumber
    ,CD.email
    ,CD.RegisterDate
    ,SUM(BD.DC_Bill)
FROM Customer_Details CD LEFT JOIN Bill_Details BD ON CD.CustomerID = BD.CustomerID
WHERE BD.Billdate Between @StartDate AND @EndDate
GROUP BY CustomerID




希望这会有所帮助,然后接受并投票回答
--Rahul D.




Hope this helps if yes then accept and vote the answer
--Rahul D.