SQL Server : aging based on last date -


rn          lsd         ed          aging ------------------------------------------ 11111111    09-feb-2017 06-feb-2017  3 22222222    09-feb-2017 02-feb-2017  7 33333333    20-jan-2017 29-nov-2016 44 33333333    20-jan-2017 07-dec-2016 44 33333333    20-jan-2017 29-nov-2016 44 33333333    20-jan-2017 30-nov-2016 44 33333333    20-jan-2017 29-nov-2016 44 44444444    12-dec-2016 19-nov-2016 17 44444444    12-dec-2016 19-nov-2016 17 44444444    12-dec-2016 25-nov-2016 17 55555555    07-feb-2017 04-dec-2016 56 55555555    07-feb-2017 04-dec-2016 56 55555555    07-feb-2017 13-dec-2016 56 

how can update aging column based on last (max) ed date column grouping rn column?

i recommend changing date format yyyy-mm-dd makes easier in calculation , sorting. should able work out difference sql query.

syntax

datediff(datepart, startdate, enddate) 

example

select datediff(day, '2014-08-05', '2014-06-05') diffdate 

Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -