Napisz przykłady tych zadań(Jak robić)
SELECT
SQL - distinct, order by, desc, limit


Odpowiedź :

Odpowiedź:

Distinct :

SELECT distinct c.CompanyName, p.ProductName

FROM Customers C JOIN orders O on c.CustomerID = o.CustomerID

       JOIN [Order Details] od on od.OrderID = o.OrderID

       JOIN products p on p.ProductID = od.ProductID

WHERE c.Country = 'USA'

Order by i desc :

SELECT

ProductName,

Discontinued,

CASE Discontinued

WHEN 0 THEN 'Nie'

WHEN 1 THEN 'Tak'

ELSE 'Brak info'

END AS 'Czy wycofany?'

FROM

Products

order by 3 desc

Limit :

SELECT column_name(s)

FROM table_name

WHERE condition

LIMIT number;

Wyjaśnienie: