- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我是 SQL (MySql) 的新手,在我的一项作业中遇到了这个问题,无法从任何人那里得到答案,也无法在线搜索有关该主题的信息。问题是这样的:
Which bikes were live (
is_live = TRUE
) on December 8? (Display onlybike_id
).
Note: The Table does not have a row entry for December 8, and that is as intendedName Type Descriptionid int LOG ID(PK)bike_id int id of the bikeis_live boolean flag to indicate whether bike is live (TRUE/FALSE)updated_on Date Date on which status of bike was updatedBIKE_LIVE_LOG table:
id bike_id is_live updated_on 1 1 TRUE 2018-12-012 2 TRUE 2018-12-013 3 TRUE 2018-12-014 3 FALSE 2018-12-025 2 FALSE 2018-12-056 3 TRUE 2018-12-10
我无法继续提出这个问题,因为根据我目前的知识,我什至没有得到解决它的方法。
我已使用此查询生成按每个 bike_id
分组的 last_update_date
。
select bll.bike_id, max(bll.updated_on) as last_update_date
from bike_live_log as bll
where bll.updated_on <= '2018-12-08'
group by bll.bike_id;
输出将为 1。
最佳答案
我会尽力帮助您完成最后一步。你真的非常接近!
您在寻找每个 bike_id
的最近 updated_on
日期的过程中是正确的。打开或关闭自行车的次数并不重要;你真的只关心你感兴趣的日期之前的最新状态。
通过您当前的查询,您已经知道每个 bike_id
的最后更新时间是在 12 月 8 日之前。
接下来,您可以使用该信息找出截至 last_update_date
每个 bike_id
值的 is_live
值。
您可以通过将现有查询用作子查询或 CTE(如果您愿意)来实现这一点,然后再次连接回您的主表。您的JOIN
标准将是bike_id
到bike_id
和 updated_on
到last_update_date
。通过加入日期,您只会为每个 bike_id
返回一条记录,并且该记录将是您感兴趣的记录。
将 JOIN
放在一起后,您只需添加一个 WHERE
子句以将结果集限制为 is_live = ' TRUE'
,它将仅返回 1
的 bike_id
。
关于mysql - 12 月 8 日直播了哪些自行车?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56461200/
这个问题更多的是关于在正确的方向上找到一个点。我继承并开发了一个项目来创建汽车选择数据库(匹配用户偏好)。它已经运行得比较好,但可能会更好(存在一些问题),所以我想研究其他人使用的其他一些算法。我正在
我有一个单词列表,例如 [bike, motorbike, copyright]。现在我想检查这个词是否由子词组成,这些子词也是独立的词。这意味着我的算法输出应该类似于:[bike, motor, m
我仍在努力思考前端状态。是否有为资源设置商店的通用最佳实践?例如,我的 web api 有: GET /bikes GET /bikes/:id 我开始时只有一个 BikeStore 和 bikes:
我是一名优秀的程序员,十分优秀!