Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Better way to do this Corelated Update ?
Want to update the SALE_CT column
to the count of C1 grouped by C1
based on value of C2......
so from this......
TEST_T
ID FLAG SALE_CT
--- ------- --------------
To like this.......
ID FLAG SALE_CT
--- --- ----------
111 Y 3 111 Y 3 111 Y 3 112 Y 1 113 Y 2 113 Y 2 114 Y 4 114 Y 4 114 N 4 114 Y 4 114 Y 4
--This DML seems to work...
update TEST_T
set SALE_CT = (select count(*)
from TEST_T b where b.ID = TEST_T.ID and b.FLAG != 'N' group by b.ID)
Do you foresee any gotchas with this DML ? I appreciate if you can suggest another way to do this.
Thanks
robert
Received on Mon Apr 22 2002 - 13:16:47 CDT