select full_query_md5, full_query_md5_d, count(*) over(partition by full_query_md5_d) from (select full_query_md5, md5(regexp_replace(regexp_replace(regexp_replace(regexp_replace(regexp_replace(regexp_replace(regexp_replace(regexp_replace(regexp_replace(regexp_replace(regexp_replace(regexp_replace(full_query, $$'[a-z]+'$$, '?', 'ig'), ' [0-9]+ ', ' ? ''g'), ' [0-9]+', ' ?', 'g'), '[0-9]+,', '?,', 'g'), '[0-9]+\)', '?)', 'g'), '\([0-9]+', '(?', 'g'), '[а-я]+', '?', 'ig'), '[0-9][0-9][0-9][0-9]-[0-9][0-9]-[0-9][0-9]', '?', 'g'), '\?,\?+', '?', 'g'), '\?,\?', '?', 'g'), $$'\?','\?'+$$, '?', 'g'), $$'\?','\?'$$, '?', 'g')) full_query_md5_d from dw.dw_queries) q order by 3 desc;
