Converted sql for first feature