Book Contents

Book Index

Next Topic

Home

clickstream_query_05.sql

Query

-- Customers coming from more than one IP address

SELECT Date_Val,

Customer_Name,

COUNT(ClientIP_Key) AS Client_IPS

FROM ClickStream_Fact A,

Date_Dimension B,

Customer_Dimension C

WHERE A.Date_Key = B.Date_Key

AND A.Customer_Key = C.Customer_Key

AND A.Date_Key > 100

AND A.Date_Key < 105

GROUP BY Date_Val,Customer_Name

HAVING COUNT(ClientIP_Key) > 10

ORDER BY Client_IPs DESC;

Example

Date_Val | Customer_Name | Client_IPS

------------+---------------+------------

2000-04-11 | Sophie | 308

2000-04-11 | Michael | 307

2000-04-11 | Samuel | 224

2000-04-11 | Hannah | 222

2000-04-11 | Emily | 214

2000-04-13 | Sophie | 213