I have been trying to research and Google forever for this but I cannot find an answer. I have duplicate values in 1 column but I would like to display them only once. Is it even possible in SQL?
What I have:
A | B | C |
---|---|---|
A | 2 | 3 |
A | 2 | 4 |
B | 4 | 4 |
B | 3 | 4 |
C | 3 | 9 |
What I would like:
A | B | C |
---|---|---|
A | 2 | 3 |
A | 4 | |
B | 4 | 4 |
B | 3 | 4 |
C | 9 |
CodePudding user response:
Use this:
SELECT A,
CASE WHEN (LAG(B) OVER (ORDER A)) = B THEN '' ELSE CONVERT(VARCHAR,B) END AS B,
C FROM TABLENAME