MDL-44524 feedback: fix bug in sql under oracle

Thanks to Rob King"