You can create a pseudo table with UNNEST for your parameter and do a left outer join:

CopySELECT t.row1, t.row2, t.row3 
FROM UNNEST(ARRAY[my_id]) i LEFT OUTER JOIN table t ON t.id = i;
Answer from clemens on Stack Overflow
๐ŸŒ
DataCamp
datacamp.com โ€บ tutorial โ€บ coalesce-sql-function
How to Use the COALESCE() Function in SQL (With Examples) | DataCamp
March 27, 2025 - This tutorial will show you how ... If all values are null, it returns null. Itโ€™s commonly used to handle missing values or combine multiple columns into one fallback output....
Discussions

coalesce more than 1 column in sql server - Database Administrators Stack Exchange
The COALESCE() function accepts more than two parameters. More on dba.stackexchange.com
๐ŸŒ dba.stackexchange.com
python 3.x - Pandas combine/coalesce multiple columns into 1 - Stack Overflow
I want to combine 2 columns into 1 in pandas, when I searched on google, the only options I got were:merge,concatenate, join. Neither of those solve the issue I'm having here. Goal: from base_dat... More on stackoverflow.com
๐ŸŒ stackoverflow.com
Coalesce usage in left outer join
cheerful shelter different homeless bells lock snobbish water complete smart This post was mass deleted and anonymized with Redact More on reddit.com
๐ŸŒ r/SQL
16
8
March 22, 2024
How to coalesce two tables with identical structure?
Coalesce won't do jack anyway. You need an aggregate since you want to take multiple rows and only return one of them. The aggregate needs to ignore null values and so effectively do a row oriented coalesce (the coalesce function is column oriented). Using order by with the aggregate will ensure that non-null overwritten values are considered first. I'm doubtful you will meet your performance requirements if you leave the data in a normalized form. More on reddit.com
๐ŸŒ r/PostgreSQL
5
2
May 16, 2021
๐ŸŒ
Reddit
reddit.com โ€บ r/dotnet โ€บ null coalesce multiple columns
r/dotnet on Reddit: NULL Coalesce Multiple Columns
December 4, 2020 - Is there an easy way to do that without a bunch of (if column1 == null then check column 2 if column 2 = null, then check column 3....)? ... In your proc just do Coalesce(col1, col2, col3, col4). ... Thank you, I guess I didn't think about doing it on the DB level first. ... Depends on the DBMS but I think most of them allow a variable number of args to the COALESCE function ... You can also nest the calls, if multiple args isn't supported.
Top answer
1 of 2
2

Looks like you need an OUTER APPLY

select
  wi.productSerial,
  wi.productName
  isnull(pp.price, ppe.price) as baseprice,
  isnull(pp.description, ppe.description) as description
from warehouseItems wi
outer apply (
    select top (1)
      pp.price,
      pp.description
    from productPrice pp
    where pp.id = wi.id
    order by pp.date
) pp
outer apply (
    select top (1)
      ppe.price,
      ppe.description
    from productPriceEast ppe
    where ppe.id = wi.id
    order by ppe.date
) ppe;
2 of 2
0

The COALESCE() function accepts more than two parameters. For example, the following is valid syntax:

SELECT COALESCE(Expression1, Expression2, Expression3, Expression4, Etc)

Not sure what you're actually stuck on?...if you could provide your table definitions, some sample data, and example expected output, it may make your goal more clear.

For example, you can concatenate two subqueries together in the same expression of the COALESCE() clause, if your goal is to show the price with the productDescrip together, like so:

SELECT 
    productSerial, 
    productName,
    COALESCE
    (
        (
            SELECT TOP 1 price
            FROM productPrice pp
            WHERE pp.id = wi.id
            ORDER BY pp.date
        ),   
        CONCAT
        (
            (
                SELECT TOP 1 price
                FROM productPriceEast ppe
                WHERE ppe.id = wi.id
                ORDER BY ppe.date
            ),
            ' ',
            (
                SELECT TOP 1 productDescrip
                FROM productPriceEast ppe
                WHERE ppe.id = wi.id
                ORDER BY ppe.date
            )
        )
    ) as baseprice
    FROM warehouseItems wi

Assuming your ORDER BY ppe.date clause is deterministic for a given ppe.id.

Or even simpler, CONCAT() the two fields inside the original subquery expression like so:

SELECT 
    productSerial, 
    productName,
    COALESCE
    (
        (
            SELECT TOP 1 price
            FROM productPrice pp
            WHERE pp.id = wi.id
            ORDER BY pp.date
        ),   
        (
            SELECT TOP 1 CONCAT(price, ' ', productDescrip) AS priceAndProductDescrip
            FROM productPriceEast ppe
            WHERE ppe.id = wi.id
            ORDER BY ppe.date
        )
    ) as baseprice
    FROM warehouseItems wi
๐ŸŒ
Microsoft Learn
learn.microsoft.com โ€บ en-us โ€บ sql โ€บ t-sql โ€บ language-elements โ€บ coalesce-transact-sql
COALESCE (Transact-SQL) - SQL Server | Microsoft Learn
The code samples in this article use the AdventureWorks2025 or AdventureWorksDW2025 sample database, which you can download from the Microsoft SQL Server Samples and Community Projects home page. The following example demonstrates how COALESCE selects the data from the first column that has ...
Find elsewhere
๐ŸŒ
TechTarget
techtarget.com โ€บ searchoracle โ€บ answer โ€บ COALESCE-on-three-columns
COALESCE on three columns | TechTarget
November 11, 2002 - insert into table2 ( foo , bar , num ) select foo , bar , coalesce( num1, num2, num3, 0 ) from table1 ยท Notice that the 0 is added as a fourth expression to guard against all three of NUM1, NUM2, NUM3 being null. Dozens more answers to tough SQL questions from Rudy Limeback.
๐ŸŒ
StrataScratch
stratascratch.com โ€บ blog โ€บ sql-coalesce-function-a-guide-for-postgresql-users
SQL COALESCE() Function: A Guide for PostgreSQL Users - StrataScratch
August 2, 2023 - The COALESCE() function returns the first non-null value from the Manufacturer and Supplier columns. If both values are NULL, then โ€˜N/Aโ€™ will replace the null value. This way, we can consolidate the provider information from multiple columns ...
๐ŸŒ
Analytics Vidhya
analyticsvidhya.com โ€บ home โ€บ coalesce function in sql
Coalesce Function in SQL - Analytics Vidhya
January 16, 2024 - In SQL Server, the Coalesce function works similarly to its general definition. It takes multiple arguments and returns the first non-NULL value from the list. However, it is important to note that the data types of the arguments must be compatible.
๐ŸŒ
Heicoders Academy
heicodersacademy.com โ€บ home โ€บ blog โ€บ guide to sql coalesce() function
Guide To SQL COALESCE() Function | Heicoders Academy
December 9, 2024 - It simplifies queries by allowing ... errors in operations. COALESCE is particularly useful in handling missing data, setting default values, and improving query logic with multiple columns....
๐ŸŒ
SQL Crash Course
sqlcrashcourse.com โ€บ sql-coalesce
Using the COALESCE function. - SQL Crash Course
SELECT CustomerName, COALESCE(HomePhone, MobilePhone, BusinessPhone) as PhoneNumber FROM Customers;
๐ŸŒ
SQLServer
bps-corp.com โ€บ post โ€บ sql-coalesce-function-handling-null-values-effectively
SQL COALESCE Function: Handling NULL Values Effectively
March 8, 2024 - SELECT COALESCE(column1, column2, column3) as result FROM mytable; The COALESCE function is a standard SQL function that is available in most relational database management systems, including Microsoft SQL Server.
๐ŸŒ
Learninka
learninka.hashnode.dev โ€บ day-13-sql-coalesce-for-multiple-columns
Day 13: SQL COALESCE for Multiple Columns
November 16, 2024 - SELECT company_name, city, postal_code, LENGTH(company_name), COALESCE(CASE WHEN LENGTH(company_name) > 15 THEN NULL ELSE city END, CASE WHEN LENGTH(company_name) > 20 THEN NULL ELSE postal_code END, 'Biggerthan20') AS Results FROM customers ORDER BY LENGTH(company_name)
๐ŸŒ
Stack Overflow
stackoverflow.com โ€บ questions โ€บ 61000544
python 3.x - Pandas combine/coalesce multiple columns into 1 - Stack Overflow
20 How to implement sql coalesce in pandas ยท 1 Combine arbitrary number of columns into one in pandas ยท 4 Combine multiple columns into 1 column [python,pandas] 0 Python Pandas combining multiple columns into single column ยท 2 Combine multiple columns of pandas data frame to one column ยท
๐ŸŒ
MSSQLTips
mssqltips.com โ€บ home โ€บ the many uses of coalesce in sql server
The Many Uses of Coalesce in SQL Server
September 30, 2022 - Once you can pivot data using the coalesce statement, it is now possible to run multiple SQL statements by pivoting the data and using a semicolon to separate the operations. Letโ€™s say you want to find the values for any column in the Person ...
๐ŸŒ
W3Schools
w3schools.com โ€บ sql โ€บ func_sqlserver_coalesce.asp
SQL Server COALESCE() Function
SQL Examples SQL Editor SQL Quiz SQL Exercises SQL Server SQL Syllabus SQL Study Plan SQL Bootcamp SQL Training ... The COALESCE() function returns the first non-null value in a list.
๐ŸŒ
Medium
medium.com โ€บ @queenskisivuli โ€บ how-to-use-the-coalesce-function-in-sql-server-1915140991d0
How to use the COALESCE function in SQL Server | by Queens Kisivuli | Medium
August 15, 2023 - In this blog post, we learned how to use the COALESCE function in SQL Server to handle NULL values in our queries. We saw some examples of how to display a default value when a column is NULL, or combine multiple columns into one and pick the first non-NULL value.
๐ŸŒ
Statology
statology.org โ€บ home โ€บ pyspark: how to coalesce values from multiple columns into one
PySpark: How to Coalesce Values from Multiple Columns into One
November 7, 2023 - Note that the coalesce function simply returns the first non-null value in each row among the columns that you specify. The following example shows how to use this syntax in practice.