Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 12890

Percentage in a query

$
0
0

Hi all, I got this query:

SELECT TEMPO, COUNT(NOME) AS NU FROM HISTORY GROUP BY TEMPO     ------ nome(nvarchar), tempo (nvarchar)

the results:

TEMPO  NU

L           13

O           8

F           25

I need another column, percentage

TEMPO NU PERCENTAGE 

where the pecentage is (Nu/SUM(nu) ) * 100

I tried with 

SELECT TEMPO, COUNT(NOME) AS NU, COUNT(NOME) OVER(PARTITION BY NOME) AS TOT FROM HISTORY GROUP BY TEMPO

but it doesn't work...any suggestion? Thanks


Viewing all articles
Browse latest Browse all 12890

Trending Articles