mariadb - mariadb Lead() 函数不接受今天的日期作为默认参数
问题描述
我正在尝试在 mysql 中使用 Lead/Lag 函数。在超前和滞后功能中,可以选择对最后一个不存在的行使用默认值。请参阅下面的文档
LEAD(expr [, N[, default]]) [null_treatment] over_clause
在上面的默认值中,我想使用curdate()函数,但它给出了错误
例如我的查询如下
SELECT
AdmissionNo,
PatientShiftDate,
timestampdiff(DAY, PatientShiftDate,
lead(PatientShiftDate, 1 , NOW() )
over ( order by IPDBedAllocationNo) ) as NoofStay
FROM
PatientBedShift
它给出了错误
#42000You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near ' curdate() ) over ( order by IPDBedAllocationNo) ) as NoofStay FROM...' at line 5
我想计算患者在每个房间停留的天数。它返回 null 而不是它应该使用 curdate()、now() 或 current_timestamp() 函数,这样我就可以获得患者在单个查询中停留的正确天数。
解决方案
推荐阅读
- python - MaxPooling2D 给出 ValueError
- list - Haskell 编译器在简单列表代码上的错误
- cuda - CUDA cudaMemcpyAsync 使用单个流来托管
- python - 通过python具有多个组的ngroup
- java - 在 Android Studio 中读取二进制数据
- python - /account/delete/testuser1 处的 AttributeError:“str”对象没有属性“field”
- javascript - React Redux - 组件不会在使用嵌套属性的状态更改时重新渲染
- discord.py - TypeError: can't send non-None value to a just-started coroutine discord.py
- c++ - 如何从用 g++ 编译的 Windows 程序中删除控制台?
- python - 如何从 pd.cut 范围中获取第一个值