在 BIRT 中根据日期统计 sql 条记录
Counting the sql records on the basis of date in BIRT
我在 sql 中有一个 table 用于记录。它包含 dateTime、id 和一些其他列。
我想在折线图中显示每个月增加或减少的记录数。
SQL 中的日期和时间格式为:2016-03-22 16:09:50.0000000
sql 服务器中此列的数据类型为 'datetime2(0)'
目前我将 'dateTime' 放在 x 轴上,'id' 放在 y 轴上。我想我可以用id来统计每个月的记录。
这是输出报告的屏幕截图。
时间显示格式不正确,我不知道如何计算每个月的记录。
请帮忙..提前致谢!!!
我建议创建一个数据集,其中包含 ID 计数和 year/month 的 varchar 字段,例如:
SELECT
CONCAT(year(yourdatetimefield), '-', month(yourdatetimefield)) AS YearMonth,
COUNT (ID) AS COUNT
FROM YourTable
GROUP BY CONCAT(year(yourdatetimefield), '-', month(yourdatetimefield))
这个returns一个year/month,每个月的ID个数
我在 sql 中有一个 table 用于记录。它包含 dateTime、id 和一些其他列。 我想在折线图中显示每个月增加或减少的记录数。
SQL 中的日期和时间格式为:2016-03-22 16:09:50.0000000 sql 服务器中此列的数据类型为 'datetime2(0)'
目前我将 'dateTime' 放在 x 轴上,'id' 放在 y 轴上。我想我可以用id来统计每个月的记录。
这是输出报告的屏幕截图。
时间显示格式不正确,我不知道如何计算每个月的记录。
请帮忙..提前致谢!!!
我建议创建一个数据集,其中包含 ID 计数和 year/month 的 varchar 字段,例如:
SELECT
CONCAT(year(yourdatetimefield), '-', month(yourdatetimefield)) AS YearMonth,
COUNT (ID) AS COUNT
FROM YourTable
GROUP BY CONCAT(year(yourdatetimefield), '-', month(yourdatetimefield))
这个returns一个year/month,每个月的ID个数