Мартин грубер понимание sql перевод Лебедева В. Н. Под редакцией Булычева В. Н. Москва, 1993 martin gruber


SELECT * FROM Orders WHERE NOT (amt = 0 OR amt IS NULL)


Download 1.45 Mb.
bet147/172
Sana26.01.2023
Hajmi1.45 Mb.
#1128343
1   ...   143   144   145   146   147   148   149   150   ...   172
Bog'liq
Грубер. Понимание SQL

SELECT *
FROM Orders
WHERE NOT (amt = 0 OR amt IS NULL);

Глава 6


SELECT COUNT(*)
FROM Orders
WHERE odate = 10/03/1990;



SELECT COUNT (DISTINCT city)
FROM Customers;



SELECT cnum, MIN (amt)
FROM Orders
GROUP BY cnum;



SELECT MIN (cname)
FROM Customers
WHERE cname LIKE 'G%';



SELECT city, MAX (rating)
FROM Customers
GROUP BY city;



SELECT odate, count (DISTINCT snum)
FROM Orders
GROUP BY odate;

Глава 7


SELECT onum, snum, amt * .12
FROM Orders;



SELECT 'For the city ', city, ', the highest rating is ', MAX (rating)
FROM Customers
GROUP BY city;



SELECT rating, cname, cnum
FROM Customers
ORDER BY rating DESC;



SELECT odate, SUM (amt)
FROM Orders
GROUP BY odate
ORDER BY 2 DESC;

Глава 8


SELECT onum, cname
FROM Orders, Customers
WHERE Customers.cnum = Orders.cnum;



SELECT onum, cname, sname
FROM Orders, Customers, Salespeople
WHERE Customers.cnum = Orders.cnum AND Salespeople.snum = Orders.snum;



SELECT cname, sname, comm
FROM Salespeople, Customers
WHERE Salespeople.snum = Customers.snum AND comm * .12;



SELECT onum, comm * amt
FROM Salespeople, Orders, Customers
WHERE rating > 100 AND
Orders.cnum = Customers.cnum AND
Orders.snum = Salespeople.snum;

Глава 9



Download 1.45 Mb.

Do'stlaringiz bilan baham:
1   ...   143   144   145   146   147   148   149   150   ...   172




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling