Internal Functions
one day, you will need them
Order of execution of SQL statements
FROM
WHERE
SELECT
ORDER BY
Concatenation Operator
select concat(first_name,last_name) as full_name
from directors limit 10;
full_name
----------------
TomasAlfredson
PaulAnderson
WesAnderson
select concat_ws(' ',first_name,last_name) as full_name
from directors limit 3;
full_name
-----------------
Tomas Alfredson
Paul Anderson
Wes Andersonif you can have a null value in column, always use
concat_wsbecause it will place nothing in that and and also not place the spacer like | or a space
Type Conversion
Implicit
data conversion is done AUTOMATICALLY
Explicit
data conversion is done via 'conversion functions' eg. CAST or ::
Casting
Formatting Functions
https://www.postgresql.org/docs/12/functions-formatting.html
to_char()
Refer to the documentation
https://www.postgresqltutorial.com/postgresql-to_char/
to_number()
https://www.postgresqltutorial.com/postgresql-to_number/
to_date()
https://www.postgresqltutorial.com/postgresql-to_date/
to_timestamp()
https://www.postgresqltutorial.com/postgresql-to_timestamp/
String Functions
Upper(string)Lower(string)INITCAP(string)REVERSE(string)LPAD(string)RPAD(string)LENGTH(string)CHAR_LENGTH(string) : Same as LengthPOSITION( string in string )STRPOS ( , < substring > )SUBSTRING (string , length)REPLACE (string, from_string, to_string)
Last updated
Was this helpful?