If you do not use the judgment operation to ensure that if any number is greater than 30, it is 30; otherwise, it is the original value (maximum limit on Field Values in SQL sorting), and 30 SQL statements
Scenario: in a database, you need to sort a specific result. When sorting, the results are sorted by different weights of several fields, but the maximum weight of one field is limited to 30.
Analysis: in SQL, is a> 30? 30: only basic operations (+-*/) and logical operations (& | xor) such as a are supported.
Answer:
(A-a % 30) & 1) * 30: When a is less than 30, a-a % 30 is 0, (0 & 1) * if the result of 30 is 0 and a is greater than or equal to 30, the final result is 30.
(A-a % 30) xor 1: When a is greater than or equal to 30, the value is 0. If a is less than 30, the result is 1.
(A-a % 30) xor 1) * (a % 30): When a is greater than or equal to 30, the value is 0. If a is less than 30, the result is.
Final: (a-a % 30) & 1) * 30 + (a-a % 30) xor 1) * (a % 30)
When a is less than 30, the partial operation before the plus sign is 0, the subsequent operation is a, and the sum is.
When a is greater than or equal to 30, the partial operation before the plus sign is 30, the subsequent operation is 0, and the sum is 30.