Oracle query - how to make count to return values with 0
2014-11-03 15:43
543 查看
Oracle query - how to make count to return values with 0
Example:select count(1), equipment_name from alarms.new_alarms where equipment_name in ( select eqp from ne_db.ne_list) Group by equipment_name
It is returning only the counts with values higher than 0 , but I need to know the records that are not returning anything.
注释:
想达到的目的是如果表
ne_list中的列
equipment_name的某一值不存在于
表new_alarms中,则能显示的列[code]equipment_name
列
equipment_name中该值在表new_alarms中为0行。[/code]
回答
Try using
LEFT JOIN,
SELECT a.eqp, COUNT(b.equipment_name) totalCount FROM ne_db.ne_list a LEFT JOIN alarms.new_alarms b ON a.eqp = b.equipment_name GROUP BY a.eqp
参考:
关于null的说明以及和0的区别
关于使用count(X) 函数的说明(附加:关于null的说明以及和0的区别)
相关文章推荐
- [转]How to get return values and output values from a stored procedure with EF Core?
- How to Make an HTTP Connection Using TCP/IP with RSocket
- HOWTO make ns-3 interact with the real world
- How to Make an HTTP Connection Using TCP/IP with RSocket
- QT18 how to link QListView with sqlite Database values
- How To Make a Simple iPhone Game with Flash CS5
- How To Make Game Art With A Distinctive Style
- How to Make LastPass Even More Secure with Google Authenticator
- How to Make an HTTP Connection Using TCP/IP with RSocket
- How To MakeUp With Your Girlfriend After A Fight
- How to Make an iOS VoIP App With Pjsip: Part 2
- QT19 How to link QComboBox with sqlite Database values
- How To Make A Side-Scrolling Beat Em Up Game Like Scott Pilgrim with Cocos2D – Part 1
- How to Make an iOS VoIP App With Pjsip: Part 4
- 转载:how to automate Microsoft Excel and return the values from a multi-cell range to an array
- How to make a Point Grey camera work with DirectShow applications/ Drivers of USB3.0 Cameras
- How To Make A Side-Scrolling Beat Em Up Game Like Scott Pilgrim with Cocos2D – Part 2
- How to Make an iOS VoIP App With Pjsip: Part 3
- How to Make Money Online with eBay, Yahoo!, and Google
- How To Make A Simple iPhone Game with Cocos2D 3.0 Tutorial