RSB
RSB

Reputation: 11

SQL Query - Correctly formatting column values (created as REAL) as INTEGER

SQL Rookie here. Using DB2.

I have a table People with attributes FirstName VARCHAR(20), Salary REAL and some others. I want to query with SELECT FirstName, Salary FROM People and receive this as the output:

FirstName    Salary
James        1000

but instead I get Salary in E Notation (because it was created as REAL):

FirstName    Salary
James        +1.00000E+003

How do I format the query to convert the values in Salary as numeric?

I tried using SELECT INTEGER(Salary) but it changes the Salary attribute header in the output to 2.

Upvotes: 1

Views: 1331

Answers (1)

Gordon Linoff
Gordon Linoff

Reputation: 1269445

Your query:

SELECT FirstName, INTEGER(Salary)
FROM People;

Does not assign a name to the second column. You assign a name using as:

SELECT FirstName, INTEGER(Salary) as Salary
FROM People;

Upvotes: 2

Related Questions