5.8 Miscellaneous Notes

SELECT * FROM EMP WHERE JOB NOT IN ('CLERK','MANAGER')-- excludes
select * from emp where comm is null -- -- is empty
select * from emp where comm  is not null -- not empty
select * from emp where hiredate > '02-April-1981' --default format
-function classification
- single-line function   operates on (multiple lines) each record, and generates a record 14---14 lower(ename),upper (ename),initcap(ename)
-- Multi-line function   operates on each record (multi-line), and the result is only one record max(sal), min(sal), sum(sal), avg(sal)

automatic conversion
select 12+'23' from dual; -- 35 + is just an arithmetic operator, automatically converted to a number
select 12+'23abc' from dual; -- error
select 12||'23abc' from dual; --  || is not an or operation , but the string concatenation operator
select * from emp where hiredate < '17-Dec-1985' -- automatic conversion
date---string --method
1: automatic conversion
select * from emp where hiredate < '17-Dec-1985'
--method 2: Manual conversion: hiredate becomes a string to_char()
select * from emp where to_char(hiredate,'YYYY/MM/DD') >'1985/12/17' --Method

3: Manual conversion: '17-12 Month-1985' becomes date to_date()
select * from emp where hiredate > TO_DATE('1985/12/17','YYYY/MM/DD')


select empno,hiredate,to_char(hiredate),to_char(hiredate,' YYYY/MM/DD')
        ,to_char(hiredate,'YYYY-MM-DD') ,to_char(hiredate,'YYYY"year"MM"month"DD"day"')from emp
multi-line function, operate multi-line data , the result is only one line

select count(distinct job) from emp; deduplicate count

 

 

 

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325965075&siteId=291194637