Subject Re: [ib-support] Using aliases in the same select clause
Author Svein Erling Tysvaer
At 14:29 29.10.2002 +0200, you wrote:
>The query at the moment looks like this which does not look very
>elegant. It works however...

Are you sure, Gerhardus? You seem to have no link between
repairauthorisation and reasonsforrejection, so I cannot see how
authoriseddate actually matters for the subselect.

Set

>select
> ra.reasonsforrejection,
> (
> select count(darno)
> from repairauthorisation
> where AUTHORISED = '0' and
> (ra.AUTHORISEDDATE between :StartDate and :EndDate)
> )as CountPerReason,
> count(ra.darno)as NumberofRejections,
> (
> cast((count(ra.darno))*100/
> (
> select count(darno)
> from repairauthorisation
> where AUTHORISED = '0' and
> (ra.AUTHORISEDDATE between :StartDate and :EndDate))as
>varchar(4))||'%'
> )as Percentage
>
>from repairauthorisation ra
>where ra.AUTHORISED = '0' and
>(ra.AUTHORISEDDATE between :StartDate and :EndDate)
>group by ra.reasonsforrejection