会员表:
ID Resident Gender Location
1 Steve M S-55
2 Roger M S-42
3 Martha F R-20
4 Samantha F CC
5 Tom M S-12
我正在尝试编写一个返回单个数值的SQL语句。
有些事情:
SELECT COUNT(Gender)
FROM Members
WHERE GENDER = M
AND Location CONTAINS 'S%'
在AND LOCATION
语法中SQL
显然不存在MALE
,但我希望得到proton | Mar 02, 2016 11:46:47 AM com.ibm.hrl.proton.webapp.providers.EventXmlNgsiMessageReader readFrom
proton | INFO: started event message body reader
proton | Mar 02, 2016 11:46:47 AM com.ibm.hrl.proton.webapp.providers.EventXmlNgsiMessageReader readFrom
proton | INFO: Event: NodeContextUpdate
proton | Mar 02, 2016 11:46:47 AM com.ibm.hrl.proton.webapp.providers.EventXmlNgsiMessageReader readFrom
proton | SEVERE: Could not parse XML NGSI event java.lang.NullPointerException, reason: null
proton | last attribute name: null last value: null
成员数量并驻留在某个位置的数量那里有一个S。
这可能吗?
答案 0 :(得分:2)
SELECT COUNT(*)
FROM Members
WHERE GENDER = 'M'
AND Location LIKE '%S%'
答案 1 :(得分:1)
SELECT COUNT(*) as count
FROM Members
WHERE GENDER = 'M' AND Location LIKE 'S%'