在Oracle查詢中,您可以使用CEIL函數對數值進行向上取整
CREATE TABLE employees (
id NUMBER PRIMARY KEY,
name VARCHAR2(50),
salary NUMBER
);
INSERT INTO employees (id, name, salary) VALUES (1, 'Alice', 5000.50);
INSERT INTO employees (id, name, salary) VALUES (2, 'Bob', 6000.25);
INSERT INTO employees (id, name, salary) VALUES (3, 'Charlie', 7000.75);
COMMIT;
SELECT id, name, CEIL(salary) AS rounded_salary
FROM employees;
這將返回以下結果:
ID | NAME | ROUNDED_SALARY
---------------------------
1 | Alice | 5001
2 | Bob | 6001
3 | Charlie | 7001
在此示例中,我們使用CEIL函數將員工薪水向上取整,并將結果作為新列"rounded_salary"返回。