Re: Average of top n query
From: Uri Dimant (urid_at_iscar.co.il)
Date: 03/22/04
- Next message: Erland Sommarskog: "Re: user sa don't have persmission to read from sysobjects rdo"
- Previous message: Tim: "Re: Stored Procedure Resultsets?"
- In reply to: David Portas: "Re: Average of top n query"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 22 Mar 2004 10:30:54 +0200
Hi, David
Yep , I was thinking to use WITH TIES but as I understood he does not
matter about the same salary.OP was not clear about that but now as I
reviewing his post I think you are right.
"David Portas" <REMOVE_BEFORE_REPLYING_dportas@acm.org> wrote in message
news:F7Gdnf1czsKwPMPdRVn-gg@giganews.com...
> > SELECT AVG(DISTINCT salary)
> > FROM Employees AS E
> > WHERE
> > (SELECT COUNT(*)
> > FROM Employees
> > WHERE salary > E.salary) < 3
>
> Oops. I think this is what I meant:
>
> SELECT AVG(DISTINCT salary)
> FROM Employees AS E
> WHERE
> (SELECT COUNT(DISTINCT salary)
> FROM Employees
> WHERE salary > E.salary) < 3
>
> --
> David Portas
> SQL Server MVP
> --
>
>
- Next message: Erland Sommarskog: "Re: user sa don't have persmission to read from sysobjects rdo"
- Previous message: Tim: "Re: Stored Procedure Resultsets?"
- In reply to: David Portas: "Re: Average of top n query"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|