I am totally new to SQL
. I have a simple select query similar to this:
SELECT COUNT(col1) FROM table1
There are some 120 records in the table and shown on the GUI
.
For some reason, this query always returns a number which is less than the actual count.
Can somebody please help me?
Try
select count(*) from table1
Edit: To explain further, count(*)
gives you the rowcount for a table, including duplicates and nulls. count(isnull(col1,0))
will do the same thing, but slightly slower, since isnull
must be evaluated for each row.
You might have some null values in col1 column. Aggregate functions ignore nulls. try this
SELECT COUNT(ISNULL(col1,0)) FROM table1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With