Oracle常用
分页查询,从第11条查询到第20条并按照sid排序:
SELECT * FROM (SELECT a.*, ROWNUM rowm FROM (SELECT * FROM STUDENT ORDER BY SID) a) b WHERE b.rowm <= 20 and b.rowm >10
判断:
decode(条件,值1,返回值1,值2,返回值2,...值n,返回值n,缺省值)
该函数的含义如下:
IF 条件=值1 THEN
RETURN(翻译值1)
ELSIF 条件=值2 THEN
RETURN(翻译值2)
......
ELSIF 条件=值n THEN
RETURN(翻译值n)
ELSE
RETURN(缺省值)
END IF
根据时间条件查询:
SELECT * FROM STUDENT WHERE TIME >= TO_DATA('2020-12-27 15:12:40', 'yyyy-mm-dd hh24:mi:ss')