Select Count(*),* from TourBooking Where MemberID = 6
发出错误
“列'TourBooking.ID'在选择列表中无效,因为它不包含在聚合函数或GROUP BY子句中。”
答案 0 :(得分:2)
您需要使用子选择:
Select (select Count(*) from TourBooking Where MemberID = 6), *
from TourBooking
Where MemberID = 6
答案 1 :(得分:2)
count()
是一个聚合函数,因此需要group by
。如果要计算结果中的总行数,可以使用窗口函数添加这样的列:
select count(*) over () as total_count,
TourBooking.*
from TourBooking
where MemberID = 6;
如果您希望表TourBooking
中的总计数<{1>} ,则需要标量子查询才能检索计数:
MemberId
答案 2 :(得分:-2)
请从
更改您的代码Select Count(*),* from TourBooking Where MemberID = 6
进入
Select Count(*) from TourBooking Where MemberID = 6