So I currently have the following SQL:
x
SELECT opportunities.ref FROM opportunities GROUP BY opportunities.ref
which returns the following results:
OP10
OP252
OP52905
OP42
I am trying to achieve the following:
'OP10'
'OP252'
'OP52905'
'OP42'
I have tried the following:
SELECT opportunities.ref FROM opportunities
CASE WHEN opportunities.ref IS NOT NULL THEN "'"+opportunitiesref+"'"
GROUP BY opportunities.ref
but this does not work.
I do not want to update the column, or use any @declare functions as this. I am currently using SQL server 2008. Im not sure how to go about this. Help?
Advertisement
Answer
If you are using SQL SERVER then modify your query according to below :
SELECT opportunities.ref FROM opportunities
CASE WHEN opportunities.ref IS NOT NULL THEN ''''+opportunitiesref+''''
GROUP BY opportunities.ref