i'm novice in sql scripts , trying counts table count 3 different ways, count(1) not issue, next 2 counts slow. there individual indexes on columns used in clause still slow. there easier , better way these count? in following code want unique customerid's on each parent-select group timestamp: (select count(distinct al2.customerid) actionlog al2 convert(varchar(10),al2.timestamp,110) = convert(varchar(10),al1.timestamp,110) , al2.actiontypeid = al1.actiontypeid , al2.campaignid = al1.campaignid , al2.eventid = al1.eventid , case when charindex('?', al2.url) > 0 left(url, charindex('?', al2.url)-1) else url end = case when charindex('?', al1.url) > 0 left(url, charindex('?', al1.url)-1) else url end , al2.timestamp between dateadd(dd, datediff(dd, 0, getdate()),-7) , dateadd(dd, datediff(dd, 0, getdate()),0)) count_total_dayunique the next 1 want new unique customerid's have not been part of parent-select group clause before...