How do I count records???

Isn’t count(1) counting rows only with non-null values in column 1, while count(*) is counting all rows?

Hmm - I just made a quick test on SQLite and there this does not seem to be the case. Also 1 does not refer to column 1, because I can use any number and it returns the correct number of rows.

I always used count() also in other databases and now I wonder whether there are dbms where count() and count(1) would produce different results?

No
You basically get a 1 for evert row the query would return (instead of other data) and the Count(1) counts all the 1’s

You can see this if you just do

select 1 from table where ….

[quote=114718:@Oliver Osswald]
I always used count() also in other databases and now I wonder whether there are dbms where count() and count(1) would produce different results?[/quote]
I’m not aware of any where the results would be different BUT I can tell you there are some where you could get noticeable speed differences

Hi! Does anybody know how to export the sample-patient information using ProteinLynx Global Server?
I have the information in the program, but when I export it, the software generates a txt file which I transfer to Excel. The problem here is that I doesn’t export the association between the corresponding protein and the patient which presented the protein in question… So I need to review it manually. :frowning:
Thank you!

Please start a new topic for this.

[quote=306345:@Rodolfo Salazar]Hi! Does anybody know how to export the sample-patient information using ProteinLynx Global Server?
[/quote]

You would probably be better off calling Waters Support in any case, if you have service contract. one person may be able to help, but he may not see it buried here, so you should start a new thread… in Off-Topic

(for those that don’t know this has to do with using Mass Spectrometry to ID proteins)

and where there will be a speed difference (for those database engines that support this)…

COUNT(8) will be faster than COUNT(*)

“8” can be any value, its not important, but to get the speed you need to specify a non-field constant

ORACLE is much faster using this method

Exactly why I said

No… what you said was there could be a noticeable speed difference… what you DID NOT indicate was WHICH method might provide that increase

FWIW its NOT certain that count(1) is always faster

Count(*) happens to be faster than COUNT(1) on Postgresql

On Oracle its the other way round

Hence

is still a good answer :slight_smile:

EDIT : You might read https://asktom.oracle.com/pls/apex/f?p=100:11:0::NO::P11_QUESTION_ID:1156159920245

I’ve seen this "count() vs. count(8)" discussion a number of times on this list. I once tested it on SQLite and posted my results to the forum (unfortunately I can’t seem to find my post anymore) which proved that count(8) was actually a bit slower there. Googling around a bit suggested that if count() is slower than count(something) than it should be considered a bug in the database engine.

In general I would appreciate it if people would try to prove their claim that some mysterious non-standard SQL is faster than what every SQL documentation on earth says by posting reproducible tests.