Skip to content

Tag: sql-server

Conditional join on soonest date – SQL Server 2017

I am working with two tables: tblOrders and tblPOs I am trying to join these two tables, and for each order, select the PO with the earliest arrival date (in the event there is more than one). So for Order Number 10244, it has two POs, PO99455 and PO99456. I would want PO99456 to be associated, since it&#8217…

Condition on SQL Server query

The below SQL query is in a SQL Server 2017. I want when the value of UtenteCliente.CostoFatturazionePersonalizzato is 0 or null is configured with the value of Utente.CostoFatturazione, to do this I use the query below but the result always returns null. How can I do this? SQL Query: Answer You can use CASE …