Number Functions: Count

Description: Returns a frequency distribution.

CREATE TABLE products (
prod1 NUMBER(3),
prod2 NUMBER(3),
prod3 NUMBER(3));
 
INSERT INTO products VALUES (34,23,45);
INSERT INTO products VALUES (34,22,34);
INSERT INTO products VALUES (54,44,45);
INSERT INTO products VALUES (23,22,45);
INSERT INTO products VALUES (45,22,34);
 
SELECT prod1, COUNT(prod1) OVER (PARTITION BY prod1) freq1,
       prod2, COUNT(prod2) OVER (PARTITION BY prod2) freq2,
       prod3, COUNT(prod3) OVER (PARTITION BY prod3) freq3
FROM products ;

Enjoyed this post? Share it!

 

Leave a comment

Your email address will not be published.