按周分组天 sql server / ssrs

发布于 2024-10-10 13:48:07 字数 309 浏览 0 评论 0原文

我将重新表述我之前提出的一个问题。

我想按周对日期进行分组。我目前有两个函数:第一个函数返回一年中的所有会计周,第二个函数返回所有日期。

我在财政周中进行了左外连接以获得此结果集。

 4/4/2010    4/4/2010 
 NULL        5/4/2010 
 NULL        6/4/2010 
 ...
 11/4/2010   11/4/2010
 NULL        12/4/2010 

在 SSRS 中,我想按周对天进行分组,因此我需要具有日期所属会计周的空值,关于如何执行此操作有什么想法吗?

I'm going to rephrase a question that I prevously had asked.

I want to group dates by week. I currently have two functions: The first of which returns all fiscal weeks of the year and the second all the dates.

I do a left outer join on the Fiscal weeks from the days to get this result set.

 4/4/2010    4/4/2010 
 NULL        5/4/2010 
 NULL        6/4/2010 
 ...
 11/4/2010   11/4/2010
 NULL        12/4/2010 

In SSRS, I want to group the days by weeek, so I need to have the Null values having the fiscal week that the dates are part of, any ideas of how to do this?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

匿名。 2024-10-17 13:48:07

我找到了另一种方法来填补空白。这是通过使用 SQL 中的 datepart 函数返回周数。

SELECT DATEPART(WEEK, specified_date)

返回星期数。然后,我在 SSRS 中周列的单元格中做了进一步的表达式,使其与原始财务周数一致,现在已经有了。

 1    4/4/2010 
 1    5/4/2010 
 1    6/4/2010 
 ...
 2  11/4/2010

这允许我在 SSRS 中按周分组。

I found an alternative way to fill the null. This was by using the datepart function within SQL to return the week number.

SELECT DATEPART(WEEK, specified_date)

Which returns the number of the week. I then did a further expression in the cell for the week column in SSRS, to make it co-align with orignal fiscal week number and now have.

 1    4/4/2010 
 1    5/4/2010 
 1    6/4/2010 
 ...
 2  11/4/2010

Which allows me to group by week in the SSRS.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文