Math Query Help

Поиск
Список
Период
Сортировка
Искать

Math Query Help

От:
<operationsengineer1@yahoo.com>
Дата:
i'm trying to work out some match queries to find
yields.

this is what i want to do... 

yield = pass / total:

(select count(inspect_pass) from t_inspect where
inspect_pass = true)/(select count(inspect_pass) from
t_inspect)

i get the following error:

ERROR:  syntax error at or near "/" at character 70

how can i fix this?

tia...

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

Re: Math Query Help

От:
George Weaver <gweaver@shaw.ca>
Дата:

----- Original Message ----- 
From: 
To: 
Sent: Tuesday, May 09, 2006 3:59 PM
Subject: [NOVICE] Math Query Help


> (select count(inspect_pass) from t_inspect where
> inspect_pass = true)/(select count(inspect_pass) from
> t_inspect)
> 
> i get the following error:
> 
> ERROR:  syntax error at or near "/" at character 70
> 
> how can i fix this?

This should work:

SELECT((select count(inspect_pass) from t_inspect where
inspect_pass = true)/(select count(inspect_pass) from
 t_inspect))

Regards,
George


Re: Math Query Help

От:
<operationsengineer1@yahoo.com>
Дата:
> ----- Original Message ----- 
> From: 
> To: 
> Sent: Tuesday, May 09, 2006 3:59 PM
> Subject: [NOVICE] Math Query Help
> 
> 
> > (select count(inspect_pass) from t_inspect where
> > inspect_pass = true)/(select count(inspect_pass)
> from
> > t_inspect)
> > 
> > i get the following error:
> > 
> > ERROR:  syntax error at or near "/" at character
> 70
> > 
> > how can i fix this?
> 
> This should work:
> 
> SELECT((select count(inspect_pass) from t_inspect
> where
> inspect_pass = true)/(select count(inspect_pass)
> from
>  t_inspect))
> 
> Regards,
> George

George, this format does run, but for other newbs out
there, it will yield a result of 0 unless you cast the
results as numeric like so:

SELECT(
  (select count(inspect_pass) 
  from t_inspect 
  where inspect_pass = true)::numeric
  /
  (select count(inspect_pass) 
  from t_inspect)::numeric
)::numeric(10,2)

in my case, this returns 0.64
 
thanks for sharing this syntax.  my searches were all
coming up empty.

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 
FAQ