|
Home > Archive > MS SQL Server MSEQ > August 2005 > Query help !
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| Ronny de Jong 2005-08-12, 7:24 am |
| Dear all,
I'd like to display the result of this query in percentage:
SELECT SYS.Client_Version0, SYS.Client_Type0, count(*) as 'Count'
FROM v_R_System as SYS
WHERE SYS.Client0=1
group by SYS.Client_Version0, SYS.Client_Type0
order by SYS.Client_Version0, SYS.Client_Type0
Any idea's how,
I appreciate your help....
Ronny
| |
| Vishal Parkar 2005-08-12, 11:24 am |
| try:
SELECT SYS.Client_Version0, SYS.Client_Type0, count(*) as 'Count',
(count(*)* cast(100 as decimal) / cnt) 'pct'
FROM v_R_System as SYS ,
(select count(*) 'cnt' from v_R_System) b
WHERE SYS.Client0=1
group by SYS.Client_Version0, SYS.Client_Type0,cnt
order by SYS.Client_Version0, SYS.Client_Type0
--Vishal
"Ronny de Jong" wrote:
> Dear all,
>
> I'd like to display the result of this query in percentage:
>
> SELECT SYS.Client_Version0, SYS.Client_Type0, count(*) as 'Count'
> FROM v_R_System as SYS
> WHERE SYS.Client0=1
> group by SYS.Client_Version0, SYS.Client_Type0
> order by SYS.Client_Version0, SYS.Client_Type0
>
> Any idea's how,
>
> I appreciate your help....
> Ronny
| |
| Hugo Kornelis 2005-08-12, 8:24 pm |
| On Fri, 12 Aug 2005 01:30:02 -0700, Ronny de Jong wrote:
>Dear all,
>
>I'd like to display the result of this query in percentage:
Hi Ronny,
SELECT SYS.Client_Version0, SYS.Client_Type0, count(*) as 'Count',
count(*) * 100.0 / (select count(*) from v_R_System) as 'Percent'
FROM v_R_System as SYS
WHERE SYS.Client0=1
group by SYS.Client_Version0, SYS.Client_Type0
order by SYS.Client_Version0, SYS.Client_Type0
(untested)
Best, Hugo
--
(Remove _NO_ and _SPAM_ to get my e-mail address)
| |
| Amit Jain 2005-08-17, 3:24 am |
| Hello Ronny,
Pls clarify the %age against the
- total records count in table or
- Total records counts in SYS.Client_Version0
As you are using 2 columns in your select query
For first case solution is already provided.
But for secound case , find the query
SELECT SYS.Client_Version0,
SYS.Client_Type0, ((count(*) * 100)/( SELECT count(*) FROM v_R_System as
Sub_SYS WHERE SYS.Client0=1 and Sub_SYS.Client_Version0 =
SYS.Client_Version0)) as 'Percentage'
FROM v_R_System as SYS
WHERE SYS.Client0=1
group by SYS.Client_Version0, SYS.Client_Type0
order by SYS.Client_Version0, SYS.Client_Type0
(Untested)
"Ronny de Jong" wrote:
> Dear all,
>
> I'd like to display the result of this query in percentage:
>
> SELECT SYS.Client_Version0, SYS.Client_Type0, count(*) as 'Count'
> FROM v_R_System as SYS
> WHERE SYS.Client0=1
> group by SYS.Client_Version0, SYS.Client_Type0
> order by SYS.Client_Version0, SYS.Client_Type0
>
> Any idea's how,
>
> I appreciate your help....
> Ronny
|
|
|
|
|