开发者

get sum of quantity in week from Tuesday To Monday

I'm using SQL SERVER 2005 and have a table which stores challans datewise. It has a fiel开发者_如何转开发d 'Quantity' I want to have a sum of Quantity for the weeks of the month. But these weeks have to start from Tuesday To Monday (this is an international standard for Oil Accounting)


You can use set DATEFIRST to set the first day of the week, and then use datepart.

These SQL Statements should get you what you want. Assumption is that your table is called and the date column is

SET DATEFIRST 2;

select datepart(week, :my_date), sum(quantity) from group by datepart(week, :my_date)

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜