Hi everyone,
I'm just learning sql and I'm trying to do the following to the pubs database:
For each order that include the books with title_id PC1035 or BU1032, list
the order number, order date, along with title_id, title, and a quantity of
each book included in order. Put the list in order of order date (in
descending order), then title in alphabetical order.
I've never written a query like that (I've done basic queries), but if
anyone can help it'd be appreciated.
Thank you,
Kristen.Kristen
The following query should help you out:
SELECT s.ord_num, s.ord_date, s.title_id, t.title, s.qty
FROM pubs.dbo.sales s JOIN pubs.dbo.titles t
ON s.title_id = t.title_id
WHERE s.title_id = 'PC1035'
OR s.title_id = 'BU1032'
ORDER BY s.ord_date DESC, t.title ASC
- Peter Ward
WARDY IT Solutions
"Kristen" wrote:
> Hi everyone,
> I'm just learning sql and I'm trying to do the following to the pubs database:
> For each order that include the books with title_id PC1035 or BU1032, list
> the order number, order date, along with title_id, title, and a quantity of
> each book included in order. Put the list in order of order date (in
> descending order), then title in alphabetical order.
> I've never written a query like that (I've done basic queries), but if
> anyone can help it'd be appreciated.
> Thank you,
> Kristen.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment