SELECT t.p rov_name AS 'level, tc ity_name AS' secondary institutions, t.s ales_name AS 'solicitors' t.i nt_value AS' number '
The FROM yl_order_table t
WHERE 1=1
Filter grade 1 - (1) department AND the CASE WHEN (SELECT COUNT (1) the FROM fr_user_city t WHERE t.v alid='t' AND t.l evel IN (1, 2, 3) AND t.u ser_code='username') & lt;> 1 0 THEN t.p rov_name IN (SELECT distinct t.org _name FROM fr_user_city t WHERE t.v alid='t' AND t.l evel IN (1, 2, 3) AND t.u ser_code='username') ELSE 1=1 END - (2) filter AND level 2 department CASE WHEN (SELECT COUNT (1) the FROM fr_user_city t WHERE t.v alid='t' AND t.l evel IN (2, 3) AND t.u ser_code='username') & lt;> 2 0 THEN tc ity_name IN (SELECT distinct t.org _name FROM fr_user_city t WHERE t.v alid='t' AND t.l evel IN (2, 3) AND t.u ser_code='username') ELSE 1=1 END - (3) filtering level 3 departments AND CASE WHEN (SELECT COUNT (1) the FROM fr_user_city t WHERE t.v alid='t' AND t.l evel=3 AND t.u ser_code='username') & lt;> 0 THEN t.s ales_name IN (SELECT distinct t.org 3 _name FROM fr_user_city t WHERE t.v alid='t' AND t.l evel=3 AND t.u ser_code='username') ELSE 1=1 END
;
CodePudding user response:
In A (... ) is considered judgment expression rather than return a value, you can then nested case again after the when, or put the t.p rov_name IN written into the back of the queryCodePudding user response: