Book Contents

Book Index

Next Topic

Home

clickstream_query_01.sql

Query

-- Customer hitting the web server the most

-- number of times in a day

SELECT Date_Val,

Customer_Name,

COUNT(*) AS Hits

FROM ClickStream_Fact A,

Customer_Dimension B,

Date_Dimension C

WHERE A.Customer_Key = B.Customer_Key

AND A.Date_Key = C.Date_Key

GROUP BY Date_Val,Customer_Name

ORDER BY Hits DESC;

Example

Date_Val | Customer_Name | Hits

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

2000-11-19 | Michael | 321

2000-03-03 | Michael | 320

2000-12-20 | Sophie | 317

2000-12-03 | Sophie | 314

2000-07-02 | Sophie | 313

2000-05-17 | Michael | 311