如何按天显示表格值
表1
ID period fromdate todate Value
001 01/2012 02/01/2012 10/01/2012 AB
002 01/2012 05/01/2012 18/01/2012 AL
....
从上表中,我想显示逐日输出。
ID,期间应从表 1 创建,然后剩余天数列应从期间生成。
日期列应根据期间创建,
例如
01/2012 means - 31 days column
02/2012 means - 29 days column
04/2012 means - 30 days column
我想显示表 1 中的值天数
预期输出
id period 1 2 3 4 5 ...10 11 12 ..18 19 ....31 total (Column Header)
001 01/2012 N AB AB AB AB .... AB N N.... N 31
002 01/2012 N N N N AL....AL AL AL...AL N .....N 31
AL、AB 应与 from 匹配表1,剩余列应显示为N,总计表示特定月份的总天数。
如何在 sql server 中执行此操作。
查询帮助期待...
Table1
ID period fromdate todate Value
001 01/2012 02/01/2012 10/01/2012 AB
002 01/2012 05/01/2012 18/01/2012 AL
....
From the above table, i want to show the day wise output.
ID, Period should create from the table1, then remaining days column should generate from the period..
Date column should create as per the period,
For example
01/2012 means - 31 days column
02/2012 means - 29 days column
04/2012 means - 30 days column
I want to show the value days wise from table1
Expected Output
id period 1 2 3 4 5 ...10 11 12 ..18 19 ....31 total (Column Header)
001 01/2012 N AB AB AB AB .... AB N N.... N 31
002 01/2012 N N N N AL....AL AL AL...AL N .....N 31
AL, AB should match with from table1, remaining column should display as N, total means total days of the particular month.
How to do this in sql server.
Query Help expecting...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要将日期格式调整为您的区域设置,但我让它在 SQL 2000(美国日期格式)中工作:
结果:
You'll need to adjust the date format to your locale, but I got this to work in SQL 2000 (USA date format):
Result: