【发布时间】:2021-10-10 04:02:48
【问题描述】:
select sum(bookID) as totalbooks, count(bookstatus = R) as returnedbooks
from library with (nolock)
where
librarylocation = 'Chesterfield'
--and bookstatus = R
所以我希望我的查询以一列的形式返回总共多少本书,但以一列的形式返回多少本书。我正在使用 count 也应用条件,但我收到错误消息:
')' 附近的语法不正确。
无论如何要做到这一点?
【问题讨论】:
-
停止使用nolock 溅出你的代码
标签: sql sql-server tsql count sum