0

I'm trying to put in an additional word in a specific column of results for a query. I've got the query fine, but I can only find how to name a specific column within a table, and not the data shown within the column, and can't find the proper query online.

I want to get the data in the column to show '50 People', instead of just '50'.

For reference this is what I've got at the moment

SELECT *
FROM SCREEN
WHERE SCREENID IN ('S1','S3')
AND BRANCHID IN ('B1','B4')
AND SCREENCAPACITY NOT LIKE '%120%'
Cœur
  • 37,241
  • 25
  • 195
  • 267
E. Pluess
  • 5
  • 1
  • 2
  • But why do you want to do that? Show us sample table data - both before and after the change. – jarlh Oct 04 '16 at 09:14
  • Are you asking how to do string concatenation in Oracle? That wouldn't help anyway if you use `SELECT *`. – Álvaro González Oct 04 '16 at 09:15
  • Perhaps `concat(columnname, ' people')`, or the ANSI SQL way `columnname || ' people'`. – jarlh Oct 04 '16 at 09:15
  • Possible duplicate of [What is the string concatenation operator in Oracle?](http://stackoverflow.com/q/278189/266304). But as already said, you can't use `*` - which is bad practice anyway. You have to list all the column names, and manipulate the one that has that value. (And why are you comparing `screencapacity`, which is hopefully a number, as a string; and why `not like`? Are you trying to only exclude 120, or also 1201, 1120, etc.?) – Alex Poole Oct 04 '16 at 09:22

1 Answers1

1

Suppose Your SCREENID is 'S1', 'S3' and you want to show 'S1 Screen' and 'S3 Screen'.

SELECT CONCAT(SCREENID, ' Screen') AS RX
FROM SCREEN
WHERE SCREENID IN ('S1','S3')
AND BRANCHID IN ('B1','B4')
AND SCREENCAPACITY NOT LIKE '%120%'
Esty
  • 1,882
  • 3
  • 17
  • 36
  • 1
    "+" is not a valid concatination operator in oracle – schurik Oct 04 '16 at 09:24
  • You would also need to specify the table name (or an alias) before `*`, i.e. `SELECT SCREEN.*, ...`; and you'll get the original value as well as the concatenated one, which probably isn't useful. Also `convert` isn't right for Oracle either. – Alex Poole Oct 04 '16 at 09:25
  • Sorry don't see oracle. I think CONCAT will be fine. – Esty Oct 04 '16 at 09:27
  • CONCAT was the one, all fixed now. Thanks so much! – E. Pluess Oct 04 '16 at 09:34