Sample Header Ad - 728x90

coalesce more than 1 column in sql server

1 vote
2 answers
268 views
I have the following query where I search 2 tables for the item price select productSerial, productName coalesce( (select top 1 price from productPrice pp where pp.id = wi.id order by pp.date), (select top 1 price from productPriceEast ppe where ppe.id = wi.id order by ppe.date) ) as baseprice from warehouseItems wi but now I want the description too, how to change the query to get more than 1 column? I cannot change the query to this since the coalesce would fail. I was thinking of select those queries in the coalesce into temp tables and do some sort of join instead of coalesce not sure if that is correct approach. select top 1 price, productDescrip from productPriceEast where ppe.id = wi.id order by ppe.date
Asked by Bigbob23 (115 rep)
Nov 30, 2023, 01:28 AM
Last activity: Nov 30, 2023, 01:08 PM