Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
[データベースシステム論] 第7回 SQL例文
--p.6
SELECT * FROM wine;
--p.7
SELECT * FROM wiNe;
--p.9
SELECT wid, name FROM wine;
--p.11
SELECT wid, name AS 名前 FROM wine;
--p.13
SELECT * FROM wine
WHERE price < 3000 AND price >= 2200;
--p.15
SELECT * FROM wine ORDER BY price ;
--p.16
SELECT name,did FROM wine ORDER BY did;
--p.17
SELECT wid,name FROM wine ORDER BY name;
--p.19
SELECT * FROM wine
WHERE price < 3000 AND price >= 2200
ORDER BY price DESC;
--p.22
SELECT avg(price) FROM wine;
SELECT round(avg(price)) FROM wine;
--p.23
SELECT string_agg(name , ’,’) FROM wine;
--p.25
SELECT did, round(avg(price)) FROM wine
GROUP BY did;
--p.26
--p.25のSQLを改造して自分でやってみよう
--p.28
--p.25のSQLを改造して自分でやってみよう
--p.29
SELECT did, round(avg(price)) AS price
FROM wine
GROUP BY did ORDER BY price DESC;
--p.30
SELECT did, round(avg(price)) FROM wine
WHERE price < 4000 GROUP BY did
ORDER BY round DESC;
SELECT did, round(avg(price)) FROM wine
GROUP BY did HAVING avg(price) < 4000
ORDER BY round DESC;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.