During data capturing, You must select and judge the SQL statement. Refer to the original script to find one of them.Decode (value, if1, then1, if2, then2,
If3, then3 ,... else) the function can meet this requirement. An error is reported after it is used. I found that this function can be used in Oracle Data and MySQL database cannot be used. How can I implement MySQL, there is a lot of information on the Internet. You can find the problem and solution on the Internet. The following describes how to use it.
Example: In Oracle (decode ):
Select sum (STI. find_questions) as findtotal, sum (STI. update_questions) as updatetotal, round (100 * (decode (sum (STI. update_questions), null, 0, sum (STI. update_questions)/(decode (sum (STI. update_questions), null, 0, sum (STI. update_questions) as zgl_0 from yujing. special_task_inspect STI where task_id =? And STI. inspect_time >=? And STI. inspect_time <=?
Corresponding to MySQL (select case when *** then *** else *** end ):
Select sum (STI. find_questions) as findtotal, sum (STI. update_questions) as updatetotal, round (100 * (select case when sum (STI. update_questions) = NULL then 0 else sum (STI. update_questions) End)/(select case when sum (STI. find_questions) = NULL then 0 else sum (STI. find_questions) End) as zgl_0 from yujing. special_task_inspect STI where task_id =? And STI. inspect_time >=? And STI. inspect_time <=?
Conclusion: as long as the key points of the problem are found, it is easy to solve the problem.
In addition, you can go to order by in use decode .
Example: TableTable_subject, YesSubject_nameColumn. Sort by language, number, and external order. This makes it easy to use.DecodeThe requirement has been completed.
Select * From table_subject order bydecode (subject_name, '', 1, 'mat', 2, '', 3)