Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: "Sum distinct"

Re: "Sum distinct"

From: David Portas <REMOVE_BEFORE_REPLYING_dportas_at_acm.org>
Date: Mon, 13 Dec 2004 23:38:32 -0000
Message-ID: <dPydnZenc9pluiPcRVn-gQ@giganews.com>


Here's one method. SQL92 except for the reserved word "value" but tested on SQL Server 2000.

SELECT M.manager, M.salary, S.value
 FROM
(SELECT manager, SUM(salary) AS salary

  FROM salesman
  GROUP BY manager) AS M,
(SELECT manager, SUM(value) AS value

  FROM salesman, sale
  WHERE salesman.id = sale.salesman_id
  GROUP BY manager) AS S
 WHERE S.manager = M.manager ;

Hope this helps.

-- 
David Portas
SQL Server MVP
--
Received on Mon Dec 13 2004 - 17:38:32 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US