Re: Nested select
- From: "David Portas" <REMOVE_BEFORE_REPLYING_dportas@xxxxxxx>
- Date: Mon, 13 Mar 2006 21:02:57 -0000
"Hugo Kornelis" <hugo@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:316912561c41ogeut35basn6lq4h00n58j@xxxxxxxxxx
On Fri, 10 Mar 2006 22:05:19 -0000, David Portas wrote:
(snip)
SELECT COUNT(*) AS countedorders
FROM
(SELECT DISTINCT [order]
FROM OrdersTable
WHERE customer='100000'
AND [order date] BETWEEN '20050101' AND '20051231'
) AS T ;
Hi David (& John),
Or even shorter:
SELECT COUNT(DISTINCT [order])
FROM OrdersTable
WHERE customer = '100000'
AND [order date] BETWEEN '20050101' AND '20051231'
(untested - see www.aspfaq.com/5006 if you prefer a tested reply)
--
Hugo Kornelis, SQL Server MVP
I wonder if Order has any nulls?
--
David Portas, SQL Server MVP
Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.
SQL Server Books Online:
http://msdn2.microsoft.com/library/ms130214(en-US,SQL.90).aspx
--
.
- Follow-Ups:
- Re: Nested select
- From: Hugo Kornelis
- Re: Nested select
- References:
- Re: Nested select
- From: David Portas
- Re: Nested select
- From: Hugo Kornelis
- Re: Nested select
- Prev by Date: Re: Help with a query please
- Next by Date: Re: Nested select
- Previous by thread: Re: Nested select
- Next by thread: Re: Nested select
- Index(es):
Relevant Pages
|
|