以下查询获得结果1中列出的结果 我希望它显示为登录用户首先显示的结果集2 IE
SELECT CLIENT_ID,
CLIENT_BRANCH BRANCH,
ACCOUNT_NO,
CLIENT_SPECIALIST
FROM CL$CLIENTS
WHERE COMPANY_ID = :P0_COMPANY_ID
当前结果
Client_id Branch Account_no CLIENT_SPECIALIST
1000001034 Training Force Isando FTEC01 LAUREN
1000001035 Training Force Isando EZUL01 Jack
1000001798 Training Force Isando ISMEP02 SAMUEL
1000002064 Training Force Parktown TTEL01 LAUREN
1000002191 Phalaborwa FOSK01 WICKUS
1000002314 Training Force Nelspruit RUD01 ERICK
1000002318 Training Force Phalaborwa SUS08 ZANELE
查询:
SELECT CLIENT_ID,
CLIENT_BRANCH BRANCH,
ACCOUNT_NO,
CLIENT_SPECIALIST
FROM CL$CLIENTS
WHERE COMPANY_ID = :P0_COMPANY_ID
ORDER by :APP_USER (First)
所需结果
Client_id Branch Account_no CLIENT_SPECIALIST
1000001034 Training Force Isando FTEC01 LAUREN
1000002064 Training Force Parktown TTEL01 LAUREN
1000002191 Phalaborwa FOSK01 WICKUS
1000002314 Training Force Nelspruit RUD01 ERICK
1000002318 Training Force Phalaborwa SUS08 ZANELE
1000001035 Training Force Isando EZUL01 Jack
1000001798 Training Force Isando ISMEP02 SAMUEL
答案 0 :(得分:0)
假设App用户出现在Client_specialist列中,您可以在order by子句中使用CASE
来生成自定义排序:
SELECT CLIENT_ID,
CLIENT_BRANCH BRANCH,
ACCOUNT_NO,
CLIENT_SPECIALIST
FROM CL$CLIENTS
WHERE COMPANY_ID = :P0_COMPANY_ID
order by case when CLIENT_SPECIALIST = :APP_USER then 0 else 1 end;