Subject | Re: [firebird-support] View output differs from straight SELECT output |
---|---|
Author | Thomas Steinmaurer |
Post date | 2012-10-23T12:17:29Z |
> Firebird 2.5RC3 (Debian version) on Debian SqueezeLooks a bit like:
>
> Trying to calculate percentages and totals (and hoping I'm getting the
> expression right):
> SELECT runs.id, count(rv.name),
> ((count(tr.resultvalue))*100)/(SELECT COUNT(resultvalue) FROM
> testresults where testresults.testrun=runs.id)
> from
> testresults tr inner join
> testruns runs on tr.TESTRUN=runs.id inner JOIN
> resultvalues rv on tr.resultvalue=rv.id
> group by runs.id, rv.name
> having rv.name='OK'
>
> gives output like
> ID COUNT DIVIDE
> 8 5 50
> (actually should mean for ID, there are 5 OKs which are 50% of the total
> results)
>
> I created a view with this SQL:
> CREATE VIEW OKRESULTS (RUNID, OKCOUNT, OKPERCENTAGE)
> AS
> SELECT runs.id, count(rv.name),
> ((count(tr.resultvalue))*100)/(SELECT COUNT(resultvalue) FROM
> testresults where testresults.testrun=runs.id)
> from
> testresults tr inner join
> testruns runs on tr.TESTRUN=runs.id inner JOIN
> resultvalues rv on tr.resultvalue=rv.id
> group by runs.id, rv.name
> having rv.name='OK';
>
> which gives output (in FlameRobin) like:
> RUNID OKCOUNT OKPERCENTAGE
> 8 5 [null]
>
> What am I doing wrong? Do I need to explicitly CAST the expression to
> e.g. a float?
http://tracker.firebirdsql.org/browse/CORE-3141
Any reason why you are using a RC of 2.5.0?
Regards,
Thomas