Tuesday, October 16, 2012

Use of COUNT function in Oracle



There might be situation like you want to delete some records from the table if the count is greater than 0.


Query :

DELETE from SAMPLETABLE where SAMPLEFIELD = 'XYZ' and (select count(SAMPLEFIELD) from SAMPLETABLE where SAMPLEFIELD = 'XYZ') > 0;