sql count列数据,求助 [英] sql count column data, help
问题描述
你好,首先我想道歉我说英语不合适..
即时通讯试图让sql querry
来计算2个不同的列中的数据......
的例子..
表名:table
列名ItemToCount(int)
ItemToCount中的
有2行,第一行是3行,另一行是4行...
这是我的命令:
hello, 1st of all i would like to appologise that i can't speak proper english..
im trying to make a sql querry
to count 2 different data from a column...
for an example..
table's name: table
column name ItemToCount (int)
in ItemToCount got 2 rows, first one is 3 and another one is 4...
this is my command :
select count(*) as NewItemToCount from table where ItemToCount = 3 and ItemToCount = 4
除了我还尝试这个命令,即使我知道它不会工作因为我使用整数而不是字符串或者字符
besides that i also try on this command even i know it won't work because im using integer but not string or character
select count(*) as NewItemToCount from table where ItemToCount = '3' and ItemToCount = '4'
但我得到的结果是
NewItemToCount = 0
任何人都可以更正我的命令,以便我可以获得2我的NewItemToCount
but the result i get is
NewItemToCount = 0
anyone can correct my command so that i can get 2 for my NewItemToCount
推荐答案
如果您使用此< br $> b $ b
if you use this
select count(*) as NewItemToCount from table where ItemToCount = 3 and ItemToCount = 4
it将仅返回0
it will return only 0
select count(*) as NewItemToCount from table where ItemToCount = 3 or ItemToCount = 4
试试这个
try this
select count(*) as NewItemToCount from table where (ItemToCount = 3 or ItemToCount = 4)
这篇关于sql count列数据,求助的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!