英文:
compare today's data with same day last week
问题
I am looking for a date function to compare data today vs last week same day. e.g., Wednesday this week vs. Wednesday last week. I am particularly looking to write in Domo (BI TOOL) but any language (SQL) would be appreciated.
Thanks
I cannot find a way to write a formula in Domo.
英文:
I am looking for a date function to compare data today vs lastweek sameday . e.g Wednesday this week vs Wednesday last week. I am particularly looking to write in Domo (BI TOOL) but any language(sql ) would be appreciated.
Thanks
I can not find a way to write formula in Domo .
答案1
得分: 1
选择 *
从您的表格 y1
左连接 您的表格 y2 在 y1.date - 7 = y2.date
英文:
select *
from your_table y1
left join your_table y2 on y1.date -7 = y2.date
答案2
得分: 0
SELECT *
FROM your_table
WHERE DAY_OF_WEEK(your_date_column) = DAY_OF_WEEK(CURRENT_DATE)
AND DATE_DIFF(your_date_column, CURRENT_DATE, WEEK) = 1
英文:
SELECT *
FROM your_table
WHERE DAY_OF_WEEK(your_date_column) = DAY_OF_WEEK(CURRENT_DATE)
AND DATE_DIFF(your_date_column, CURRENT_DATE, WEEK) = 1
答案3
得分: 0
这不清楚你试图实现什么。你想要比较两个日期之间的汇总值吗?
这将为您提供两行数据,一行是今天(星期四),另一行是上个星期四:
SELECT date_col, SUM(something), AVG(something_else)
FROM your_tabl
WHERE date_col = CURRENT_DATE
OR date_col = DATE_SUB(CURRENT_DATE, INTERVAL 1 WEEK)
GROUP BY date_col
我已经使用了Beast Mode函数参考指南中记录的函数。
英文:
It is not clear what you are trying to achieve. Are you wanting to compare aggregate values between the two dates?
This would give you two rows, one for today (Thursday) and another for last Thursday:
SELECT date_col, SUM(something), AVG(something_else)
FROM your_tabl
WHERE date_col = CURRENT_DATE
OR date_col = DATE_SUB(CURRENT_DATE, INTERVAL 1 WEEK)
GROUP BY date_col
I have used the functions documented on Beast Mode Functions Reference Guide.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论