當前位置:首頁 » 編程語言 » 三道sql題目
擴展閱讀
webinf下怎麼引入js 2023-08-31 21:54:13
堡壘機怎麼打開web 2023-08-31 21:54:11

三道sql題目

發布時間: 2022-08-09 01:06:47

① Oracle plsql編程的三道題目

4、使用case語句更新工資,10部門提高100,20部門提高200,30部門提高300,40部門提高400。

setserveroutputon
declarev_dptemp.dpt%type;
begin
selectdptintov_dptfromempwherename='zhangsan'
case
whenv_dpt='10'then
updateempsetsal=sal+100wherename='zhangsan';
whenv_dpt='20'then
updateempsetsal=sal+200wherename='zhangsan';
whenv_dpt='30'then
updateempsetsal=sal+300wherename='zhangsan';
whenv_dpt='40'then
updateempsetsal=sal+400wherename='zhangsan';
else
dbms_output.put_line('無法更新!');
endcase;
end;

5、分別使用3種循環計算10的階乘

簡單(loop)循環

declareinumber(2):=1;snumber(10):=1;
begin
loops:=s*i;
i:=i+1;
dbms_output.put_line(s);
exitwheni>10;
endloop;
end;

for循環

declareinumber(2):=1;snumber(10):=1;
begin
loop
s:=s*i;
i:=i+1;
dbms_output.put_line(s);
exitwheni>10;
endloop;
end;

while循環

declareinumber(2):=1;snumber(10):=1;
begin
whilei<=10loop
s:=s*i;
i:=i+1;
dbms_output.put_line(s);
endloop;
end;

6、使用for循環輸出一個實心三角形,底邊長由用戶輸入。

核心代碼:

begin
foriin1..5loop
dbms_output.put_line(rpad(i,8-i,'')||rpad('*',2*i-1,'*'));
endloop;
end;

② 3道題目SQL怎麼做大家幫幫我

4)
insert into Employees(EmployeeID, Name, Birthday, Sex, Address, Zip, PhoneNumber, EmailAddress, DepartmentID) values ('210678', '林濤', '1973-5-1', '1', '中山北路3號', '210002', '4055663', NULL, '5')
5)
update Employees set Birthday='1967-4-2' where Name = '林濤'
6)--存儲過程
create procere insertEmployees
@Employeeid varchar(20),@Name varchar(20),@Birthday datetime,@Sex char(1),
@Address varchar(300),@Zip varchar(6),@PhoneNumber varchar(20),
@EmailAddress varchar(50),@DepartmentID varchar(30)
as
begin
insert into Employees
(EmployeeID, Name, Birthday, Sex, Address, Zip, PhoneNumber,
EmailAddress, DepartmentID)
values(@EmployeeID, @Name,@Birthday, @Sex, @Address, @Zip, @PhoneNumber,
@EmailAddress, @DepartmentID)
end
--調用存儲過程
exec insertEmployees '308759',' 葉凡', '1968-1-1','1', '北京西路3號',
'210001', '33089056', NULL, '4'

③ 求 3道SQL選擇題,稍微有點難度的

1.隱藏系統資料庫操作中使用到的菜單命令是( )。
A 、選中要隱藏的系統資料庫後選擇 [ 操作 ] 4 [ 屬性 ] 菜單命令
B 、選中要隱藏的系統資料庫後選擇 [ 查看 ] 4 [ 自定義 ] 菜單命令
C 、選中 SQL Server 伺服器後選擇 [ 操作 ] 4 [ 編輯 SQL Server 注冊屬性 ] 菜單命令
D 、都可以
2.下面關於 SQL Server 登錄賬戶敘述錯誤的是( )。
A 、 默認情況下, Windows 的系統管理員賬戶自動成為 SQLServer 登錄賬戶
B 、在企業管理器中可修改 Windows 登錄賬戶的登錄密碼
C 、在企業管理器中可修改 SQL Server 登錄賬戶的登錄密碼
D 、SQL Server 安裝在 Windows NT 或 2000 中才有 BUILTI NAdministrators 登錄賬戶,否則只有 sa 賬戶
3.下列關於對象瀏覽器敘述錯誤的是( )。
A 、在編輯查詢時,可將資料庫、表或欄位名稱拖放到查詢窗口中
B 、將資料庫或欄位名稱拖放到查詢窗口中可直接添加資料庫或欄位名稱
C 、拖放表名,可在查詢中添加該表的所有欄位名稱
D 、拖放模板,可添加模板中的 SQL 命令
4.下列關於關系資料庫敘述錯誤的是( )。
A、 關系資料庫的結構一般保持不變,但也可根據需要進行修改
B 、一個數據表組成一個關系資料庫,多種不同的數據則需要創建多個資料庫
C 、關系數據表中的所有記錄的關鍵字欄位的值互不相同
D 、 關系數據表中的外部關鍵字不能用於區別該表中的記錄
5.下列關於資料庫的數據文件敘述錯誤的是( )。
A 、創建資料庫時必須指定數據文件
B 、創建資料庫時, PRIMARY 文件組中的第一個文件為數數據文件
C 、一個資料庫可以有多個數據文件
D 、一個資料庫只能有一個主數據文件
6.在使用 Recordset 對象時,如果要查看其他用戶的更改操作,則應將游標類型定義為( )。
A 、動態游標或鍵集游標
B 、鍵集游標或靜態游標
C 、靜態游標或僅向前游標
D 、僅向前游標或動態游標

④ sql語句 面試題

A.創建表格CODE省略

註明:學生表PK stu_id 課程表pk cos_id 分數表PK enrollment_id FK stu_id,cos_id

B.插入數據code省略

C.Query

  1. select s.stu_id,stu_name,count(cos_id) from student s,enrollments e where s.stu_id = e.stu_id and e.grade>60 group by s.stu_id,stu_name;

  2. select e.stu_id,s.stu_name,c.cos_name from student s,enrollments e,course c

    where s.stu_id = e.stu_id

    and e.cos_id = c.cos_id

    and c.cos_name = 'CHINESE'

    and s.stu_name like 'W%';

  3. select stu_id,stu_name from (select e.stu_id,stu_name,cos_name from enrollments e,student s,course c

    where s.stu_id = e.stu_id

    and e.cos_id = c.cos_id

    and c.cos_name IN ('CHINESE','MUSIC'))

    group by stu_id,stu_name

    having count(cos_name) = 2

  4. select distinct e.cos_id,c.cos_name,count(e.stu_id) stu_count,count(e.stu_id)-NVL(A.FAIL,0) upscore,(count(e.stu_id)-NVL(A.FAIL,0))/count(e.stu_id) rate from

    (select cos_id,count(stu_id) fail from enrollments where grade<60 group by cos_id) a,enrollments e,course c

    where e.cos_id = a.cos_id(+)

    and e.cos_id = c.cos_id

    group by e.cos_id,NVL(a.fail,0),c.cos_name;

  5. update student

    set avg_grade =(select avg(grade) X from enrollments group by stu_id

    having student.stu_id = enrollments.stu_id);

  6. select stu_id,avg(grade) from

    (select stu_id,cos_id,grade,row_number() over(partition by stu_id order by grade ) X from enrollments)

    group by stu_id

    having count(*)<=2

    UNION

    select A.stu_id,avg(A.grade)from

    (select stu_id,cos_id,grade,row_number() over(partition by stu_id order by grade ) X from enrollments) A,

    (select stu_id,count(*) c from

    (select stu_id,cos_id,grade,row_number() over(partition by stu_id order by grade ) X from enrollments)

    group by stu_id) B

    where A.stu_id = B.stu_id

    and A.x>1 and x<B.c

    group by A.stu_id,b.c

_________________________________________________

環境:oracle 10g/TOAD 以上代碼均通過測試,如有問題,請聯系,謝謝

⑤ 哪位大蝦幫忙解下三道SQL語句題,謝了,在線等,急急急!!!

第一題的 1 關系代數實現 應該是 πgrade((πsno='李明'(student)∞sc) ÷π(δcname='資料庫原理'(course)))
那個自然連接我沒找到對應的符號,用無窮大代替了

⑥ SQL語句問題 3道簡單的題 最好再給我簡單講講

第一個:查詢計算機專業「計算機導論」課程的學生姓名、課程名、成績,並按成績降序排列
select a.姓名,b.課程名,c.成績 from 學生信息表 a,課程信息表 b,成績信息表 c
where a.學號=c.學號
and b.課程號=c.課程號
and a.專業名='計算機'
and b.課程名='計算機導論'
order by 成績 desc
第二個:查詢「計算機導論」課程成績高於80分的學生學號、姓名、專業名;
select a.學號,a.姓名,a.專業名 from 學生信息表 a,課程信息表 b,成績信息表 c
where a.學號=c.學號
and b.課程號=c.課程號
and b.課程名='計算機導論'
and c.成績>80
第三個:查詢「計算機導論」課程成績高於80分的學生學號、姓名、課程名、成績;
select a.學號,a.姓名,b.課程名,c.成績 from 學生信息表 a,課程信息表 b,成績信息表 c
where a.學號=c.學號
and b.課程號=c.課程號
and b.課程名='計算機導論'
and c.成績>80

⑦ sql資料庫這三道題應該怎麼做

注意:小寫的字母為表的別命名,欄位大小寫沒有區分,你要是區分的話區分下,sql 查詢器裡面可以設置

  1. 查詢訂單金額最高的客戶名、貨品名稱、購買數量、金額和下單時間。

    select c.cname 客戶名,p.pname 貨品名稱,o.quantity 購買數量,max(o.money)金額,o.orderdate下單時間

    from Customer c,Proct p, Orders o

    where c.cid=o.cid and o.oid=p.pid

2.查詢庫存量低於10的商品名稱

select p.pname 貨品名稱

from Proct p

where p.quantity<10

3.

假設訂單表Orders已創建,為該表添加默認值約束,訂單日期為當前日期

Alter table Orders Alter Column 訂單日期 datetime default getdate()

⑧ 高分求SQL資料庫三道小題

1.select 客戶ID,姓名
form 租賃,客戶
where 客戶. 客戶ID=租賃.客戶ID and 設備ID='筆記本'
2.select *
from 租賃
where 設備ID is null
3.select 設備類別,count(設備ID),sum(設備表.日租金*租賃表.租期)
from 設備,租賃
group by 設備類別

⑨ SQL高手請進高分請你做3道簡單的題目

問題一:要求不清晰,借書和還書這個要求不明確
問題二:
select b.books_name,c.user_name
from lease a, books b, user c
where a.books_ID=b.books_ID and a.user_ID=c.user_ID
and loan_date between '2006-07-02' and '2007-07-05'
問題三:
select b.books_name,c.user_name
from lease a, books b, user c
where a.books_ID=b.books_ID and a.user_ID=c.user_ID
and YEAR(loan_date) = '2006'

⑩ 高分懸賞幾道計算機SQL資料庫的題!做出來了先支付100分,要是滿意的話,在加賞50~

1. 查詢雇員(employee)的姓和名

Select substring(username,1,1) as 姓 from employee
Select substring(username,2,2) as 名 from employee

2. 查詢雇員的姓名
Select username from employee
3. 查詢雇員數
Select count(*) from employee
4. 查詢雇員的姓名和職務
Select username,,ty from employee
5. 查詢雇員的工齡
Select year(getdate())-開始工作日期 as 工齡 from employee
任務2:條件查詢
1. 查詢雇員(employee)從事"Sales Representative"職務的有哪些人

Select * from employee where ty=』 Sales Representative』
2. 查詢工齡超過15年的雇員
Select * from employee where cast( (year(getdate())-開始工作日期) as int)>=15
3. 查詢姓以a開頭的雇員
Select * from employee where username like 『a%』
4. 查詢姓的開頭字母在m以後的雇員
Select * from employee where cast((substring(username,1,1) as varchar)>=』m』

5. 認為hire_date是雇員生日,查詢巨蟹座的雇員

Select * from employee where birthday between 『6-22 『 and 『7-22』
任務3:聯合查詢
1. 查詢雇員和雇員職位

Select a.id,b.ty from employee, as a,jobs as b
2. 查詢雇員、雇員職位和雇員所在出版社

Select a.id,b.ty, b.publishing from employee as a,jobs as b on a.id=b.id
3. 查詢雇員、雇員工資、雇員離本職位最高工資的差值
select a. ID,a.username,a.[雇員工資],b.[最高工資]-a.[雇員工資] as [差值] from employee a,jobs b where a.[職位]=b.[職位]