如何使用分组方式 [英] How to use group by
本文介绍了如何使用分组方式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我按甲骨文遇到了一个问题,我正在尝试将所有病房的服务费超过2500英镑归为一类.我有两个病房和病床,病房都在两个表中.这是我所拥有的以及我不断得到的错误:
I have a group by problem with oracle, I'm trying to group together all wards which have service charges over £2500. I have two tables Ward and Bed, wardno is in both tables. Here is what I have and the error I keep getting:
SELECT HospitalCode, Ward.WardNo, Bed.WardNo, BedNo, TotalServiceCosts,
FROM WARD, BED
GROUP BY TotalServiceCosts >= 2500
ORA-00936: missing expression
有人可以帮我解决丢失的表情吗?
Can someone help me with the missing expression?
推荐答案
错误!删除TotalServiceCosts
之后的逗号!
您需要将查询更改为:
Error! Remove the comma after TotalServiceCosts
!
You need to change your query as:
SELECT HospitalCode, Ward.WardNo, Bed.WardNo, BedNo, SUM(TotalServiceCosts)
FROM WARD, BED
GROUP BY HospitalCode, Ward.WardNo, Bed.WardNo, BedNo
HAVING SUM(TotalServiceCosts) >= 2500
在TotalServiceCosts
之后删除逗号!您不能在此处使用WHERE
子句.在GROUP BY
的情况下,HAVING
替代WHERE
.
Remove the comma after TotalServiceCosts
! You cannot use a WHERE
clause here. HAVING
is an alternate to WHERE
in case of GROUP BY
.
这篇关于如何使用分组方式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文