|
cplusplus
Aged Yak Warrior
567 Posts |
Posted - 2011-08-22 : 20:03:20
|
| Is it possible i need an update statement.I built a sample table with data.ID field is unique in the below @sample table example:you can see all rows with projid 59 has same amounts, and some with zero orderamts.once i execute update it has to make all zeros except on row keep the value 143.23---Get all unique rows based on projid and ID, in case of projid 59there are 7 rows, update all orderamt = 0 and exclude just the Max(ID) row , where there is a orderamt value, with projid=43.Is it possible to run the update via query to take care of all rows.Declare @Sample table (ID int, proid int, orderamt float)insert @Sampleselect 23, 59,'0' union allselect 34, 59,'143.23' union allselect 63, 59,'143.23' union allselect 77, 59,'0' union allselect 89, 59,'0' union allselect 90, 59,'143.23' union allselect 112,59,'0' union allselect 114,43,'223.32' union allselect 117,43,'0' union allselect 118,43,'223.32' union allselect 121,43,'223.32' union allselect 131,43,'0' union allselect 132,43,'223.32'Thank you very much for the helpful info. |
|