How to append measurement units in Select Statement in SQL Query within the output

StackOverflow https://stackoverflow.com/questions/23341888

  •  11-07-2023
  •  | 
  •  

سؤال

I'm using Oracle's SQL Developer.

For example, I've table City with two columns - place and speed_limit. Column speed_limit has datatype number(3) and I want query with select statement with return column speed_limit with units (mph) in the output in column speed_limit.

What I should add to the query?

SELECT speed_limit
FROM city;

to have output like this:

speed_limit 
-----------
    20 mph
    40 mph
   100 mph

instead of:

speed_limit 
-----------
    20
    40
   100
هل كانت مفيدة؟

المحلول

SELECT TO_CHAR(speed_limit) || ' mph'
FROM city
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top