Click here to Skip to main content
15,897,518 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
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 :
SQL
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
SQL
select count(*) as NewItemToCount from table where ItemToCount = '3' and ItemToCount = '4'


but the result i get is
NewItemToCount = 0

anyone can correct my command so that i can get 2 for my NewItemToCount
Posted

if you use this

SQL
select count(*) as NewItemToCount from table where ItemToCount = 3 and   ItemToCount = 4


it will return only 0

SQL
select count(*) as NewItemToCount from table where ItemToCount = 3 or ItemToCount = 4
 
Share this answer
 
Comments
arnoldxx 14-Mar-14 8:25am    
Thx bro.. Its work :D
King Fisher 14-Mar-14 8:26am    
:)
try this
select count(*) as NewItemToCount from table where (ItemToCount = 3 or ItemToCount = 4)
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900