Quantcast
Channel: Teradata Forums - Database
Viewing all articles
Browse latest Browse all 14773

COUNT () OVER (PARTITION BY) and DISTINCT - response (1) by dnoeth

$
0
0

Hi Gwen,
SELECT DISTINCT is processed after the OPAP function and COUNT(DISTINCT)  can't be used in OLAP, but in this case you don't need it, just GROUP BY first:

SELECT
    name
    , hair_colour
    , COUNT(hair_colour) OVER (PARTITION BY name)
FROM
    MyTable
GROUP BY 
    name
    , hair_colour;

Dieter


Viewing all articles
Browse latest Browse all 14773

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>