Skip to content

Tag: sql

SQL Subtract from different tables

I’m subtracting values from diferent tables based on ID. Its like an inventory where I’ve the tables for Itens In and Itens Out. What I want to do is to substract the Itens In – Itens Out based on ID …

Looping in SQL with TempTable

I am new to SQL Server, can you please help me to write query for my scenario? I have this Table1 : Input to my stored procedure is a PolicyNumber e.g 1234 and the code should return 5 rows. I need to cover these cases: If the first payment is not cancelled, I need return that row. If the first