Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.databases.ms-sqlserver > #1173

Re: Need help to update table based on previous rows column values

From Erland Sommarskog <esquel@sommarskog.se>
Newsgroups comp.databases.ms-sqlserver
Subject Re: Need help to update table based on previous rows column values
Date 2012-07-13 11:14 +0200
Organization Erland Sommarskog
Message-ID <XnsA08F72578D53Yazorman@127.0.0.1> (permalink)
References <f06f1d6e-7af7-476e-8808-2b1524163b0f@googlegroups.com> <ef77549d-59a5-4a3a-8778-519fb3b11277@googlegroups.com>

Show all headers | View raw


Dinesh (dinesht15@gmail.com) writes:
> Thanks for the reply. It is working but having one issue. It is setting
> first row value for each CUstID as NULL which should not happen. First
> row (Lowest date) for each customer should have RefilWritten. 

Could add "WHERE RefillLeft IS NULL" to the UPDATE statement.


-- 
Erland Sommarskog, SQL Server MVP, esquel@sommarskog.se

Links for SQL Server Books Online:
SQL 2008: http://msdn.microsoft.com/en-us/sqlserver/cc514207.aspx
SQL 2005: http://msdn.microsoft.com/en-us/sqlserver/bb895970.aspx

Back to comp.databases.ms-sqlserver | Previous | NextPrevious in thread | Find similar


Thread

Need help to update table based on previous rows column values Dinesh <dinesht15@gmail.com> - 2012-07-09 11:21 -0700
  Re: Need help to update table based on previous rows column values Erland Sommarskog <esquel@sommarskog.se> - 2012-07-09 23:43 +0200
  Re: Need help to update table based on previous rows column values Dinesh <dinesht15@gmail.com> - 2012-07-12 23:27 -0700
    Re: Need help to update table based on previous rows column values Erland Sommarskog <esquel@sommarskog.se> - 2012-07-13 11:14 +0200

csiph-web