You are here: Re: Return percentages in the query. « MsSQL Server « IT news, forums, messages
Re: Return percentages in the query.

Posted by Madhivanan on 10/15/06 03:49

Try

select count(sid), /* all not the not null */
count(*),
(count(sid)*1.0 / count(*) ) as percent_not_null,
4 as four,
(3/4) as three_over_four
from dbo.sysusers


Madhivanan


sqlservernewbie@yahoo.com wrote:
> Hello,
>
> I'm trying to something that just works in Oracle, but does not in Sql
> Server.
>
> How can I get the percentage of two counts to be returned on each row
> of the query?
>
> select count(sid), /* all not the not null */
> count(*),
> (count(sid) / count(*) ) as percent_not_null,
> 4 as four,
> (3/4) as three_over_four
> from dbo.sysusers
>
>
> 70 82 0 4 0
>
>
> Incredibly, it changes even 3/4 into a zero!
>
> For efficiency, I want the percentage returned in the query.
> And to not use variables and coding. Efficiency,
> both of the server, and of my time.
>
>
> Note: I am using dbo.sysusers as an EXAMPLE only. My real
> query will be on user defined application tables.
>
>
> What is the solution please?

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация