Hi, I am writing a stored procedure and trying to do an inline query on the same table:
ALTER PROCEDURE djLink_sp_GetBrowserStats
AS
Declare @TotalBrowsers int
Select @TotalBrowsers = Count(*) From djLink_tblBrowsers
Select
Distinct
BrowserName,
( Select Count(*) From djLink_tblBrowsers Where BrowserName = djLink_tblBrowsers.BrowserName) As Total,
(( Select Count(*) From djLink_tblBrowsers Where BrowserName = BrowserName) / @TotalBrowsers * 100) As Percentage
From
djLink_tblBrowsers
|
The problem is on this line (and the line preceeding):
(Select Count(*) From djLink_tblBrowsers Where BrowserName = djLink_tblBrowsers.BrowserName) As Total
Basically because I am doing the query in the same table it is getting confused and counting all rows, not just ones with the same browser name.
Is there anyway to get around this?
Thanks, Mart.