102年警察二等 資料庫 - 考試
By Zora
at 2014-04-25T14:37
at 2014-04-25T14:37
Table of Contents
版上的各位好,我這邊有一題SQL查詢語法的問題,希望大家幫我看看我的觀念正不正確,
寫完沒正確解答可以對照總覺得不太穩,尤其是第(四)題,麻煩各位了,謝謝!
題目:
https://www.dropbox.com/s/t6utc5q266oxw5r/102_1.jpg
我的答案:
(一)
SELECT Car.CarNo, Car.Name, Car.Brand, Car.Model, Car.Color
FROM Car JOIN Speeding ON Car.CarNo = Speeding.CarNo
WHERE KM=63 AND Date BETWEEN '2013/4/1' AND '2013/4/15'
(二)
SELECT CarNo, Name, Brand, Model, Color, Engine
FROM Car
WHERE Name IN
(
SELECT Name
FROM Car
WHERE Engine > 3200
GROUP BY Name
HAVING COUNT(*) >= 2
)
(三)
SELECT Car.CarNo, Car.Name, Speed
FROM Car JOIN Speeding ON Car.CarNo = Speeding.CarNo
WHERE Speed >= ( SELECT MAX(Speed) FROM Speeding )
(四)
SELECT CarNo
FROM Car
WHERE NOT EXISTS
(
SELECT *
FROM ( SELECT * FROM Speeding GROUP BY Highway ) AS hw
WHERE NOT EXISTS
(
SELECT *
FROM Speeding
WHERE hw.Highway = Speeding.Highway AND
Car.CarNo = Speeding.CarNo
)
)
--
寫完沒正確解答可以對照總覺得不太穩,尤其是第(四)題,麻煩各位了,謝謝!
題目:
https://www.dropbox.com/s/t6utc5q266oxw5r/102_1.jpg
我的答案:
(一)
SELECT Car.CarNo, Car.Name, Car.Brand, Car.Model, Car.Color
FROM Car JOIN Speeding ON Car.CarNo = Speeding.CarNo
WHERE KM=63 AND Date BETWEEN '2013/4/1' AND '2013/4/15'
(二)
SELECT CarNo, Name, Brand, Model, Color, Engine
FROM Car
WHERE Name IN
(
SELECT Name
FROM Car
WHERE Engine > 3200
GROUP BY Name
HAVING COUNT(*) >= 2
)
(三)
SELECT Car.CarNo, Car.Name, Speed
FROM Car JOIN Speeding ON Car.CarNo = Speeding.CarNo
WHERE Speed >= ( SELECT MAX(Speed) FROM Speeding )
(四)
SELECT CarNo
FROM Car
WHERE NOT EXISTS
(
SELECT *
FROM ( SELECT * FROM Speeding GROUP BY Highway ) AS hw
WHERE NOT EXISTS
(
SELECT *
FROM Speeding
WHERE hw.Highway = Speeding.Highway AND
Car.CarNo = Speeding.CarNo
)
)
--
Tags:
考試
All Comments
By Tristan Cohan
at 2014-04-30T09:09
at 2014-04-30T09:09
By Edwina
at 2014-05-05T00:00
at 2014-05-05T00:00
By Ingrid
at 2014-05-07T18:45
at 2014-05-07T18:45
By Puput
at 2014-05-12T11:37
at 2014-05-12T11:37
By Necoo
at 2014-05-15T22:52
at 2014-05-15T22:52
By Donna
at 2014-05-16T15:11
at 2014-05-16T15:11
By George
at 2014-05-19T18:59
at 2014-05-19T18:59
By Selena
at 2014-05-24T10:23
at 2014-05-24T10:23
By Harry
at 2014-05-28T02:39
at 2014-05-28T02:39
By Jessica
at 2014-05-30T14:04
at 2014-05-30T14:04
By Caitlin
at 2014-06-02T10:10
at 2014-06-02T10:10
Related Posts
數位電子學
By Candice
at 2014-04-25T11:43
at 2014-04-25T11:43
不知今年關務機械3等有無解答
By Anonymous
at 2014-04-25T10:30
at 2014-04-25T10:30
資料結構
By Jessica
at 2014-04-25T10:16
at 2014-04-25T10:16
電路學
By Gilbert
at 2014-04-25T09:03
at 2014-04-25T09:03
新手發問地特/初等以及補習班函授的問題
By Elvira
at 2014-04-25T01:42
at 2014-04-25T01:42