Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Updating value from last entered value

Status
Not open for further replies.

Santysri1976

IS-IT--Management
Aug 17, 2016
2
IN
I am having a database like
Childid Month Height
1 Jan-2019 12.5
1 Feb-2019 null
1 Mar-2019 null
1 Apr-2019 13.5
2 Jan-2019 10.0
2 Feb-2019 null
2 Mar-2019 10.5

Now I want a query which will update null value in height with last taken month and the result should be like
Childid Month Height
1 Jan-2019 12.5
1 Feb-2019 12.5
1 Mar-2019 12.5
1 Apr-2019 13.5
2 Jan-2019 10.0
2 Feb-2019 10.0
2 Mar-2019 10.5
 
Update Table M set M.height = (Select top 1 S.height from Table S where S.height not null and M.childid = S.childid order by S.childid S.month descending) where M.height is null;

untested

==================================
advanced cognitive capabilities and other marketing buzzwords explained with sarcastic simplicity


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top