Oracle基礎之三

2021-09-10 06:31:00 字數 2131 閱讀 3578

3.select[distinct]*|列名稱[別名],列名稱[別名],…列名稱[別名]

①from 表名稱[別名]

②[where 過濾條件(s)]

④[order by 字段 [asc|desc],字段[asc|desc]…字段[asc|desc]]

order by 是在select 後面執行的,所以可以唯一使用別名進行排序。

asc由低到高

desc是由高到低

select *from emp order by sal;

select empno,ename,sal*12 income from emp order by income;

選擇部門30的所有員工

select * from emp where deptno=30;

列出所有辦事員(clerk)的姓名,編號和部門編碼

select ename,empno,deptno from emp where job='clerk';

找出佣金高於薪水的60%的員工

select * from emp where comm>sal*0.6;

找出部門10中所有經理和部門20中的所有辦事員

第一組條件:deptno =10 and job =『manager』

第二組條件:deptno =20 and job =『clerk』

第三條件為:or

select * from emp where (deptno =10 and job ='manager') or (deptno =20 and job ='clerk');

找出部門10中所有經理和部門20中的所有辦事員,即不是辦事員跟經理但其薪金高於2000的員工

第一組條件:deptno =10 and job =『manager』

第二組條件:deptno =20 and job =『clerk』

第三組條件:job not in (『manager』,『clerk』) and sal >=2000

第三條件為:or

select * from emp where (deptno =10 and job ='manager') or (deptno =20 and job ='clerk') or (job not in ('manager','clerk') and sal >=2000);

找出收取佣金的員工的不同工作

-工作一定有重複,既然重複就需要使用distinct消除重複資料

select job from emp where comm is not null;沒有去除重複

select distinct job from emp where comm is not null;去除重複

顯示不帶有r的員工姓名

select * from emp where ename not like '%r%';

顯示名字字段任何位置有a的員工,顯示按照基本工資進行由高到低排序,如果一樣則按僱傭年限又早到晚排序,如還一致,則按職位排序

條件一:找出名字a的員工

select * from emp where ename like '%a%';

條件二:工資高到低

select * from emp where ename like '%a%' order by sal desc;

條件三:僱傭年限早到晚

select * from emp where ename like '%a%' order by sal desc,hiredate desc;

條件四:職位排序

select * from emp where ename like '%a%' order by sal desc,hiredate desc,job desc;

1,清楚使用:select,from where, order by字句

2,多條件判斷時候一定要用邏輯連線,而且盡量使用 " () " 來做乙個區分

3,遇到問題慢慢分析,乙個乙個步驟寫

python基礎之三

import module name 直接匯入 module name.func 呼叫函式時,需要模組名作為字首 from module name import function name 不用使用模組名作為字首 from module name import 匯入模組下的所有函式和類注 pytho...

oracle學習記錄之三

1.用profile管理使用者密碼安全 create profile lock account limit failed login attempts 3 password lock time 2 需要管理員許可權才能建立 alter user xiaoming profile lock accou...

Spring基礎之三 annotation配置注入

用annotation配置只在源 相應的地方加入annotation即可,xml就不用再來回來去改了,開發時候快,不過我覺得沒xml清楚。其中這兩句是新加且必須的,新加了乙個命名空間 xml的namespacexmlns context 其實annotation全寫對了的話,配置檔案就是最上邊那樣了...