I am trying to achieve a query where I have this data.
A%
A%%
A%%%
A%%%%%
A%%%%%
B%%%
B%%%
I want to group them by and ignoring the wildcard character %, The output I expect from this query is like this.
A
B
CodePudding user response:
You could just strip off the %
characters and then aggregate:
SELECT DISTINCT REPLACE(val, '%', '') AS val
FROM yourTable;
CodePudding user response:
You can use standard string REPLACE function and group by column you wanted:
SELECT
REPLACE(yourColumnName, '%', '')
FROM
yourTable
GROUP BY
REPLACE(yourColumnName, '%', '')