my $select = "SELECT SQL_CALC_FOUND_ROWS defaultusers.id, defaultusers.birthday, defaultusers.name, defaultusers.count_img, defaultusers.wohnort, IF(sessions.userid IS NOT NULL, '1','0') FROM defaultusers LEFT JOIN sessions ON defaultusers.id = sessions.userid WHERE defaultusers.status = 'N' ORDER BY IF(defaultusers.count_img >=1, 1, defaultusers.count_img) DESC, defaultusers.lastlogin DESC LIMIT $db_show, 8";