❔ SQL Server | Count How Much Installment Paid and Left
#ask #query # sql server
hi i have a question,
last week my teacher give a task to select data from table claim and
count how much installment already paid and left in SQL Server,
My teacher said claim is paid every month until Claim.LastPaymentDate
im already done to arrange the data like the first image but im really confuse to count how much installment paid and left, already searching in google but i cant find the correct answer, is anyone know to do that ?
9 Replies
what are you even googling for this? It sounds like a simple math question, use the created/last dates to calculate how many months there are. Then use the payment date to determine how many months are left/paid and with that you can determine how much has been paid and is left
sry i didnt make it a clear,
so the real issue is how do i count it in SQL Server ?
so if im using c#
but in SQL Server im really confuse to do it
it is clear. you just need to do some simple date math to calculate how many installments there are, and how many have been paid
yeahhh..... lets change a question a little bit,
so u know how to store a selected data into array in SQL Server and Looping it?
why would you need to store anything into an array here and loop it?
im just thinking to do the same method in c# to SQL Server
and do a bunch of select an inserting
my brain cant think of doing it with only a single select query
Installments = months between created/last
RemainingInstallments = (months between created/last) - (months between created/payment)
seems simple enough
just rest my brain a bit and some smol research,
by using datediff and subquery i finally understand what u say
here my final query
is there a way to improve this query ?
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.