I want to select only distinct values from each column. Not distinct combination. Here is my query but its returning distinct combination of all columns. i want that each column show its own distinct values without depending on other columns.
$sql= "select distinct
CASE WHEN col1 not regexp '[0-9]' THEN col1 else null end as col1
,CASE WHEN col2 not regexp '[0-9]' THEN col2 else null end as col2
,CASE WHEN col3 not regexp '[0-9]' THEN col3 else null end as col3 from table_name";
It returns this:
col1| col2| col3
a 1 3
b 2 4
c 2 4
d 1 3
you guys could see that the values of col2 and col3 are not distinct i want only distinct from col2 and col3 too. Thanks!
but not working
? Can you show us sample data and what your desired output is? – Tim Biegeleisendistinct col1, col2, col3
... and yourcase
stmt does not impact that – Drew