home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / database / 5785 < prev    next >
Encoding:
Internet Message Format  |  1992-07-25  |  2.0 KB

  1. Path: sparky!uunet!cs.utexas.edu!zaphod.mps.ohio-state.edu!pacific.mps.ohio-state.edu!linac!att!ucbvax!mtxinu!sybase!robert
  2. From: robert@sybase.com (Robert Garvey)
  3. Newsgroups: comp.databases
  4. Subject: Re: Sybase questions
  5. Keywords: count, aggregates
  6. Message-ID: <21537@sybase.sybase.com>
  7. Date: 22 Jul 92 23:02:51 GMT
  8. References: <1992Jul16.220952.2833@asc386> <1992Jul17.124748.13088@glv.uucp>
  9. Sender: news@Sybase.COM
  10. Followup-To: comp.databases
  11. Distribution: usa
  12. Organization: Emeryville Tupleware
  13. Lines: 44
  14.  
  15. (Early attempt to followup was not successful, as far as I can tell.)
  16.  
  17. In article <1992Jul17.124748.13088@glv.uucp>, bob@robjob@glv.com (Robert H. Lunney) writes:
  18. |> In article <1992Jul16.220952.2833@asc386> mosmith@asc386 (Matt Smith) writes:
  19. |> > 
  20. |> > [...method of finding number of rows in a table...]
  21. |> > 
  22. |> 
  23. |> This is true, but T-SQL will not count rows where the column contains a null.   
  24. From the Commands Reference pages on aggregates:
  25.  
  26.   COUNT - finds the number of non-null values in a column.  When
  27.      DISTINCT is specified, COUNT finds the number of unique
  28.      non-null values.  COUNT can be used with numeric and character
  29.      columns.  Null values are ignored for the purposes of counts.
  30.  
  31.   COUNT(*) - finds the number of rows.  COUNT(*) does not take any
  32.      arguments, and cannot be used with DISTINCT.  All rows are
  33.      counted, regardless of the presence of null values.
  34.  
  35. An example:
  36.  
  37. select * from foo   select count(bar) from foo
  38.  bar
  39.  --------            -----------
  40.  NULL                         10
  41.  NULL
  42.  AAAAAA             select count(distinct bar)
  43.  aaaaaa             from foo
  44.  BBBBBB
  45.  CCCCCC              -----------
  46.  CCCCCC                        8
  47.  cccccc
  48.  DDDDDD             select count(*) from foo
  49.  EEEEEE
  50.  eeeeee              -----------
  51.  eeeeee                       12
  52.  
  53. -- 
  54. Robert Garvey                                Sybase, Inc
  55. robert@sybase.com                            6475 Christie Ave
  56. {sun,lll-tis,pyramid,pacbell}!sybase!robert  Emeryville, CA 94608-1010
  57.  
  58. Anything related to an opinion may be attributed solely to the poster.
  59.