以下查询获得结果1中列出的结果 我希望它显示为登录用户首先显示的结果集2 IE
SELECT CLIENT_ID,
CLIENT_BRANCH BRANCH,
ACCOUNT_NO,
CLIENT_SPECIALIST
FROM CL$CLIENTS
WHERE COMPANY_ID = :P0_COMPANY_ID
结果1 :(实际输出)
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)
结果2(期望输出)
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)
SELECT CLIENT_ID,
CLIENT_BRANCH BRANCH,
ACCOUNT_NO,
CLIENT_SPECIALIST
FROM CL$CLIENTS
WHERE COMPANY_ID = :P0_COMPANY_ID
ORDER BY DECODE(client_specialist, :APP_USER, 1, 2)
这表示客户专家的订单,当值=:APP_USER然后将其放在第一位,否则为第二位。