Skip to main content

Posts

Showing posts with the label update statement with self subquery in SQL

update statement with self subquery in SQL

Below is the example of update statement with self subquery in SQL. UPDATE TB1 A SET A.IND = 'N', A.ENDDT = (Select Max(C.enqDT) -1 from TB1 C where A.Bus_KEY = C.BusKEY and C.IND ='Y' group by C.BusKEY) Where A.IND = 'Y' and A.EFFDT < (Select max(enqDT) From TB1 B Where B.col1 = A.col1 and B.bus_KEY = A.busKEY and B.IND = 'Y');