-4

select DISTINCT column1, (select DISTINCT column2 from table1 ) from table1

I want both column1 and column2 value without duplicate

  • 2
    Can you please add some info clearly with result output. select distinct column1,column2 from table would do – Ven Jun 22 '17 at 10:51
  • Can you present example data you have and expected result? – Pablo notPicasso Jun 22 '17 at 11:08
  • .i was working in month selection table with column1 contain n number of month name in english and column2 contain n number of month name in local language. i want month in english & local language in 12 rows with two column without duplication – Ratheesh krishna Jun 22 '17 at 11:15

4 Answers4

1

SELECT DISTINCT value FROM Table1 CROSS APPLY ( VALUES ('COLUMN1', Column1), ('COLUMN2', Column2) ) c(col, value) WHERE value IS NOT NULL

0
select distinct column1
               ,column2
from table1 
iamdave
  • 12,023
  • 3
  • 24
  • 53
Pablo notPicasso
  • 3,031
  • 3
  • 17
  • 22
  • i don't know if he is asking for that ,for example [a,b][a,c] ar not duplicate in row but in column according with what he is asking . – Frank Jun 22 '17 at 10:53
  • i tried it but not Working...i was working in month selection table with column1 contain n number of month name in english and column2 contain n number of month name in local language. i want month in english & local language in 12 rows with two column without duplication – Ratheesh krishna Jun 22 '17 at 11:02
0

If you have only few duplicates, then

SELECT DISTINCT Column1, Column2 from table1

If you have many duplicates, then

SELECT Column1, Column2 from table1 GROUP BY Column1, Column2
Arun Nadaraj
  • 153
  • 1
  • 3
  • 14
  • 1
    Why do you think there is a difference between these two statements? They are syntactically identical and doing the same thing inside the SQL Engine – iamdave Jun 22 '17 at 10:54
0

select distinct column1,column2 from table1;