Friday, May 15, 2009

Precheck before increment a field

This will return max()+1 other wise 1 if no records is there.

select
           case
                     when count(*) > 0
           then
                     max(eno)+1
           else
                     1
           end as max
from
           emp




No comments:

Post a Comment