UserIdが1回以上リストされている場合は+1し、「新規ユーザー」には+1、それ以外の場合は「返すユーザー」にカウントしなければなりません。ありとあらゆる行の数をカウントします。SQL
私が行っているがあります:
select
Count(distinct [UserId]) as 'Unique users'
from [TelemetryData]
where [DiscountId] = '8CAEA860-6766-43E2-9280-27AFE7FDF82E' and [EventName] = 'DiscountClick'
/* returning */
select
count(Id) as 'Returning users'
from [TelemetryData]
where [DiscountId] = '8CAEA860-6766-43E2-9280-27AFE7FDF82E' and [EventName] = 'DiscountClick'
group by [UserId]
having count(Id) > 1
/* returning */
select
count(*) as 'New users'
from [TelemetryData]
where [DiscountId] = '8CAEA860-6766-43E2-9280-27AFE7FDF82E' and [EventName] = 'DiscountClick'
group by [UserId]
having count(*) = 1
を私は「帰国」と「新」のユーザーは、最初のクエリのように、クエリの行の合計NUMERを数える必要があります。どうやってするの?
これは、SQL Serverのコードのように見えるので、私はそのタグを追加しました。 –