home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!cs.utexas.edu!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!ucbvax!mtxinu!sybase!robert
- From: robert@sybase.com (Robert Garvey)
- Newsgroups: comp.databases
- Subject: Re: Sybase questions
- Keywords: count, aggregates
- Message-ID: <21537@sybase.sybase.com>
- Date: 22 Jul 92 23:02:51 GMT
- References: <1992Jul16.220952.2833@asc386> <1992Jul17.124748.13088@glv.uucp>
- Sender: news@Sybase.COM
- Followup-To: comp.databases
- Distribution: usa
- Organization: Emeryville Tupleware
- Lines: 44
-
- (Early attempt to followup was not successful, as far as I can tell.)
-
- In article <1992Jul17.124748.13088@glv.uucp>, bob@robjob@glv.com (Robert H. Lunney) writes:
- |> In article <1992Jul16.220952.2833@asc386> mosmith@asc386 (Matt Smith) writes:
- |> >
- |> > [...method of finding number of rows in a table...]
- |> >
- |>
- |> This is true, but T-SQL will not count rows where the column contains a null.
- From the Commands Reference pages on aggregates:
-
- COUNT - finds the number of non-null values in a column. When
- DISTINCT is specified, COUNT finds the number of unique
- non-null values. COUNT can be used with numeric and character
- columns. Null values are ignored for the purposes of counts.
-
- COUNT(*) - finds the number of rows. COUNT(*) does not take any
- arguments, and cannot be used with DISTINCT. All rows are
- counted, regardless of the presence of null values.
-
- An example:
-
- select * from foo select count(bar) from foo
- bar
- -------- -----------
- NULL 10
- NULL
- AAAAAA select count(distinct bar)
- aaaaaa from foo
- BBBBBB
- CCCCCC -----------
- CCCCCC 8
- cccccc
- DDDDDD select count(*) from foo
- EEEEEE
- eeeeee -----------
- eeeeee 12
-
- --
- Robert Garvey Sybase, Inc
- robert@sybase.com 6475 Christie Ave
- {sun,lll-tis,pyramid,pacbell}!sybase!robert Emeryville, CA 94608-1010
-
- Anything related to an opinion may be attributed solely to the poster.
-