Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.tools -> Re: How to "Group By" a calculated field?
In article <994757278.634582_at_proxy.storm.co.za>, "Lee says...
>
>I am trying to construct a query that requires grouping by a calculated
>value (something like "to_char(:RptDate, 'MM')-to_char(OrderDate, 'MM')". I
>would have created a view that does the calculation, and used that, but the
>calculation is based on a parameter value. So how can I get around this?
>
>Thanks.
>
>Lee.
>
>
select ...., to_char(:RptDate, 'MM')-to_char(OrderDate, 'MM'), ... from ... group by ..., to_char(:RptDate, 'MM')-to_char(OrderDate, 'MM')
or
select ..., C, .... from ( select ...., to_char(:RptDate, 'MM')-to_char(OrderDate, 'MM') C, ... from ... )
-- Thomas Kyte (tkyte@us.oracle.com) http://asktom.oracle.com/ Expert one on one Oracle, programming techniques and solutions for Oracle. http://www.amazon.com/exec/obidos/ASIN/1861004826/ Opinions are mine and do not necessarily reflect those of Oracle CorpReceived on Tue Jul 10 2001 - 08:45:38 CDT