sql - Select distinct combinations of values -


i have table x values , y values, both int. want group on x value condition contains distinct combination of y values. want see total number of each combination.

i tried using sum ( power (2, y)), generates numbers big y can 300 in cases.

+--------------+--------------+ |            x |            y | +--------------+--------------+ |            1 |            1 | |            1 |            2 | |            1 |            4 | |            1 |            6 | |            2 |            1 | |            2 |            2 | |            2 |            4 | |            2 |            6 | |            3 |            2 | |            3 |            3 | |            3 |            5 | |            4 |            2 | |            4 |            3 | |            4 |            5 | |            5 |            2 | |            5 |            3 | |            5 |            6 | +--------------+--------------+ 

i want result like:

+--------------+--------------+ |            x |        count | +--------------+--------------+ |            1 |            2 | |            3 |            2 | |            5 |            1 | +--------------+--------------+ 

based on description (but not on sample data) next query should do:

select x, count(distinct y) tbl group x 

Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -