all AI news
Handling NULLs in PostgreSQL: Alternatives to ISNULL
May 23, 2024, 7 a.m. | DbVisualizer
DEV Community dev.to
Learn about effective alternatives to the ISNULL function in PostgreSQL, focusing on COALESCE and CASE statements.
PostgreSQL's approach to NULL values includes functions like COALESCE, which handles multiple inputs:
-- PostgreSQL
SELECT COALESCE(salary, 0) AS salary
FROM employee;
The CASE statement also provides a method for conditional NULL handling:
-- PostgreSQL
SELECT CASE WHEN salary IS NULL THEN 0 ELSE salary END AS salary
FROM employee;
FAQ
Why do some SQL databases have ISNULL while PostgreSQL does not?
ISNULL is …
case coalesce employee function functions inputs learn multiple null postgresql salary values
More from dev.to / DEV Community
Jobs in AI, ML, Big Data
Senior Data Engineer
@ Displate | Warsaw
Professor/Associate Professor of Health Informatics [LKCMedicine]
@ Nanyang Technological University | NTU Novena Campus, Singapore
Research Fellow (Computer Science (and Engineering)/Electronic Engineering/Applied Mathematics/Perception Sciences)
@ Nanyang Technological University | NTU Main Campus, Singapore
Java Developer - Assistant Manager
@ State Street | Bengaluru, India
Senior Java/Python Developer
@ General Motors | Austin IT Innovation Center North - Austin IT Innovation Center North
Research Associate (Computer Engineering/Computer Science/Electronics Engineering)
@ Nanyang Technological University | NTU Main Campus, Singapore