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

Home -> Community -> Usenet -> comp.databases.theory -> Re: Can I do this using SQL?

Re: Can I do this using SQL?

From: Volker Hetzer <volker.hetzer_at_ieee.org>
Date: Thu, 09 Feb 2006 16:34:02 +0100
Message-ID: <dsfnda$3lg$1@nntp.fujitsu-siemens.com>


dhruv schrieb:
> Hi,
> Thanks a lot! Ok, so let me get this straight... If I have a count(),
> min(), max, avg() on the projection list, then I can use it with group
> by and the aggregate will be applied on EACH GROUP? Also, is ORDER BY
> always applied last(on the final result set).
>
> Also, if I have a HAVING clause, will it too be applied on each GROUP?
>
> If so, then can I always emulate HAVING by using subqueries, by
> projecting the fields after the HAVING keyword, and putting the
> condition after the HAVING keyword in the WHERE of the outher select?
>

If you think it's too complex, do a nested query. Something like

select branch, branchcardinality

	from
		(
		select branch, count(cust_id) as branchcardinality
			from customers
			group by branch
		)
	order by branchcardinality desc

Probably easier to recognize in six months.

Lots of Greetings!
Volker Received on Thu Feb 09 2006 - 09:34:02 CST

Original text of this message

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