比较今天的数据与上周同一天的数据。

huangapple go评论93阅读模式
英文:

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.

huangapple
  • 本文由 发表于 2023年6月15日 09:27:06
  • 转载请务必保留本文链接:https://go.coder-hub.com/76478511.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定