Re: Nested select



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
.



Relevant Pages

  • Re: Nested select
    ... Or even shorter: ... WHERE customer = '100000' ... Hugo Kornelis, SQL Server MVP ...
    (microsoft.public.sqlserver.mseq)
  • Re: For an article: What do you wish your CIO understood about requirements?
    ... snip ... ... I wanted to rework the whole thing to disconnect the interactions, ... and replace many custom routines by table driven standard ... required rewriting for almost every customer. ...
    (comp.programming)
  • Re: Perl script to clean up file -- Dont know if it can be done
    ... > This is the problem I get a file that I must pull the pertanent data out. ... I need to pull out just the columns. ... Where did the extra CUSTOMER HAS line come from? ...
    (comp.lang.perl.misc)
  • Re: Attitude of Plusnet reps on ADSL Guide
    ... clearly dont what im saying is if other people have had shit service doesnt ... that would be the current plusnet customer then would it as opposed to the ...
    (uk.telecom.broadband)
  • Re: over-dramatic press releases
    ... I propose is like the "preferred customer" clubs that many ... for a while it helped that chain, but then the others did it to ... It's kind of like the trend to rename faculties as "schools" because the big boys did it. ...
    (sci.research.careers)