Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- SELECT
- toStartOfMonth(DATE) AS MONTH
- ,uniq(
- toUInt32OrZero(
- multiIf( EXTRACT(request_uri, '/category/[a-z\-]*([0-9]{2,7}).*')<>''
- , EXTRACT(request_uri, '/category/[a-z\-]*([0-9]{2,7}).*')
- , extractURLParameter(request_uri, 'category_id')<>''
- , extractURLParameter(request_uri, 'category_id')
- , extractURLParameter(request_uri, 'categories_id')<>''
- , extractURLParameter(request_uri, 'categories_id')
- , visitParamExtractString(post_params, 'categories_id') <> ''
- , visitParamExtractString(post_params, 'categories_id')
- , ''
- )
- ) AS categories_id
- ) AS unq_categories_id
- , uniq(customers_id) AS unq_customers_id
- , uniq(concat(toString(categories_id),'_', toString(customers_id))) AS cnt_view_categories
- , multiIf(
- MATCH(user_agent, 'MamsyApp'), 'MamsyApp'
- , MATCH(user_agent, 'iPhone|iPad|iPod|Android|Windows Phone'), 'Mobile'
- , 'Desktop'
- ) AS platform
- FROM site_request AS sr
- WHERE customers_id != 0
- AND DATE >= '2019-01-01'
- AND categories_id IS NOT NULL
- AND categories_id != 0
- AND date_added >= dictGetDateTime('categories','date_start',toUInt64( categories_id ))
- AND date_added <= dictGetDateTime('categories','date_end',toUInt64( categories_id ))
- GROUP BY MONTH, platform
- -- having unq_customers_id > 20
- ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement