Get Sign of the column value in Postgresql

In order to get sign of the column value in postgresql we use SIGN() function. SIGN() Function in postgresql gets negative (-1) or positive value (1). Let’s see how to

  • Get Sign of the column value in postgresql –  SIGN()

Get SIGN() in Postgresql:

SIGN() function in posgresql gets the sign of the value

SELECT SIGN(-5.7) AS "Sign_value";

So sign of the value will be

Get Sign of the column value in Postgresql 1

 

Get Sign of the column value in Postgresql table:

We use table states

Get Sign of the column value in Postgresql 2


SELECT *,SIGN(hindex_score) as sign_hindex  from STATES

We have created a column and stored the Sign value of hindex_score. So the resultant table will be

Get Sign of the column value in Postgresql 3

 

                                                                                                         

Author

  • Sridhar Venkatachalam

    With close to 10 years on Experience in data science and machine learning Have extensively worked on programming languages like R, Python (Pandas), SAS, Pyspark.