Hi , I have a query which is taking a lot of time because of a Distinct column.Ca any one suggest how can i remove the distinct and replace with any other functions like PARTITION BY to get the output.
My Query:
SELECT
date
, NAME
, LONG
, LAT
, COUNT ( DISTINCT IMEI) + COUNT ( DISTINCT CASE WHEN IMEI IS NULL THEN 1 END) AS NUMBER_OF_DISTINCT_USERS
, MAX(MAT) MARKET
FROM poc.CP_TEST
WHERE date = to_timestamp('20190130','YYYYMMDDHH24') - INTERVAL '1 DAY'
and MAT like '%Light%'
GROUP BY
date
,NAME
,LONG
,LAT
I want to replace that distinct with some other functions...