sql - Big query to find row count for unique visit where purchase is null -


i have table

visit_num   visid_high  visid_low   visit_page_num  purchase   1            123        456              1          null   1            123        456              2           12   2            123        556              1          null   2            123        556              2          null   2            123        556              3          null   2            123        556              4          null 

and wanted count of rows unique visit_num+visid_high+visid_low purchase null. here, visit_page_num id of page user visited , visit defined concatenation of visid_high, visid_low , visit_num. have written query row count purchased null, below big query statement

select   count(unique(concat(string(visid_high), string(visid_low), string(visit_num)))) visits,   table_name   purchased null 

and found row count 2, wrong, should 1. query gives row count below row well.

visit_num   visid_high  visid_low   visit_page_num  purchase   1            123        456              1          null 

however visit comes purchase value visit_page_num id 2

visit_num   visid_high  visid_low   visit_page_num  purchase   1            123        456              2          null 

can me write query row count unique visit purchase null. in advance. :)

select    count(visit) visits (   select     concat(string(visid_high), string(visid_low), string(visit_num)) visit,     count(purchase) purchases       table_name   group 1   having purchases = 0 ) 

Comments

Popular posts from this blog

sql - invalid in the select list because it is not contained in either an aggregate function -

Angularjs unit testing - ng-disabled not working when adding text to textarea -

How to start daemon on android by adb -