蜂巢查询从前一天开始计数

发布于 2025-02-05 08:24:09 字数 365 浏览 3 评论 0原文

表A。

年度(字符串),月(字符串)和天(字符串)是分区列。

我想获得前一天的计数。

请注意 - 这里没有日期的日期,例如2022-- 06-01在任何列中,

了以下查询

(*)

我尝试 。 - 编码值。

Table A
Name City    Year    Month   Day
ABC     Mumbai  2022    05      31
ABC     Mumbai  2022    06      01
ABC     Mumbai  2022    06      02
ABC     Mumbai  2022    06      03
ABC     Mumbai  2022    06      04

Year(String), Month(String), and Day(String) are partition columns.

I want to get the count for the previous day.

Note - here no Date formate like 2022-06-01 in any columns

I tried the below query.

Select count(*) FROM Table A where Day='03' and Month='06' and Year='2022' GROUP BY city;

But I don't want to hard-coded value.

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

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

发布评论

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

评论(1

又爬满兰若 2025-02-12 08:24:09

我认为我得到了解决方案 -

从表A中选择计数(*)where cast(concat_ws(' - ',Year,“月,每天”)作为日期)= date_sub(current_date,1);

这给了我正确的结果。

I think I got the solution -

select count(*) from Table A where cast(concat_ws('-',year,month,day) as date)=date_sub(current_date, 1);

this is giving me the correct results.

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