Skip to content

Instantly share code, notes, and snippets.

@yucao24hours
Last active December 23, 2015 12:19
Show Gist options
  • Save yucao24hours/6634711 to your computer and use it in GitHub Desktop.
Save yucao24hours/6634711 to your computer and use it in GitHub Desktop.
テーブルSales,Customers,Employees,Productsを結合して、Sales.Quantityが200以上のデータについてQuantity,CustomerName,ProductName,EmployeeNameを表示しなさい。JOINを用いずに書きなさい。(SQL書き方ドリル / 第3章 その2 第4問)
SELECT
s.Quantity
, c.CustomerName
, p.ProductName
, e.EmployeeName
FROM
Sales AS s
JOIN
Customers AS c
ON
s.CustomerID = c.CustomerID
JOIN
Employees AS e
ON
e.EmployeeID = s.EmployeeID
JOIN
Products AS p
ON
p.ProductID = s.ProductID
WHERE
s.Quantity >= 200
;
SELECT
s.Quantity
, c.CustomerName
, p.ProductName
, e.EmployeeName
FROM
Sales AS s
, Customers AS c
, Employees AS e
, Products AS p
WHERE
s.Quantity >= 200
AND
s.CustomerID = c.CustomerID
AND
s.ProductID = p.ProductID
AND
s.EmployeeID = e.EmployeeID
;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment