Re: SELECT COUNT(*)
From: Sue Hoegemeier (Sue_H_at_nomail.please)
Date: 02/15/05
- Next message: Wayne Snyder: "Re: SELECT COUNT(*)"
- Previous message: arthur: "more unintuitive behavior"
- In reply to: Mike Epprecht (SQL MVP): "SELECT COUNT(*)"
- Next in thread: Wayne Snyder: "Re: SELECT COUNT(*)"
- Messages sorted by: [ date ] [ thread ]
Date: Tue, 15 Feb 2005 07:18:38 -0700
That is a good question. I'd only guess it's something
implemented similar to Oracle to allows things such as
select GetDate() without the from clause. The from clause is
suppose to be required in every select statement.
In Oracle, the from is always required so if you used their
implementation of the same and used dual, select count(*)
from dual should return 1 if I remember correctly.
In other words, I'd guess SQL Server and Sybase implement
something similar to the dummy table dual but you just don't
have to be explicit with it such as you do in Oracle.
-Sue
On Tue, 15 Feb 2005 05:03:03 -0800, "Mike Epprecht (SQL
MVP)" <mike@epprecht.net> wrote:
>Hi
>
>select count(*) where 1=2
>go
>
>select count(*)
>go
>
>Results:
>-----------
>0
>
>-----------
>1
>
>What is "select count(*)" counting ?
>
>Where 1=1 ?
>
>Same behavior in SQL 7.0, 2000 and Sybase. Oracle, it does not work with
>error "Missing FROM clause".
>
>--------------------------------
>Mike Epprecht, Microsoft SQL Server MVP
>Zurich, Switzerland
>
>MVP Program: http://www.microsoft.com/mvp
- Next message: Wayne Snyder: "Re: SELECT COUNT(*)"
- Previous message: arthur: "more unintuitive behavior"
- In reply to: Mike Epprecht (SQL MVP): "SELECT COUNT(*)"
- Next in thread: Wayne Snyder: "Re: SELECT COUNT(*)"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|