Hey @chen_guangyu, you would probably have better luck using a filter() function rather than facet cases. To quote an older post of mine:
I’ve got a sticky note on my monitor that says “filter, not facet cases” as a reminder because I often find myself in situations in which I try to use FACET or FACET cases to write a query when what I really needed was the filter function.
The filter function allows you to select on subsets of data, similar to using FACET cases. However, unlike FACET cases, the filter function can have faceting applied to all filtered sections, can take multiple facets, and is not “greedy”. FACET cases are considered “greedy” in that any results that match on a specific case will not be available to be matched on for any subsequent cases.
I would try a query like this:
SELECT filter(uniqueCount(session), WHERE appName=‘MyApp’) AS ‘Total Sessions’, filter(uniqueCount(session), WHERE appName = ‘MyApp’ and pageUrl like ‘%home/adminurl%’) AS ‘Admin Sessions’ FROM PageView SINCE ‘2018-11-16’ WITH TIMEZONE ‘America/New_York’
Another good option would be to use a funnel query. Funnels only pass matched events from one step into the WHERE clause of the following step, narrowing in on data one step at a time. My favorite thing about funnel charts is that they provide information “at a glance”, reducing time to resolution. Here’s an example of a funnel that may meet your needs:
WHERE appName=‘MyApp’ AS ‘Total Sessions’,
WHERE appName=‘MyApp’ AND pageUrl LIKE ‘%home/adminurl%’ as ‘Admin Sessions’)
SINCE ‘2018-11-16’ WITH TIMEZONE ‘America/New_York’