按SQL中的两个不同条件列出列

时间:2021-06-05 22:44:10

Here is the query I am trying to execute: Repeat Question 13, but also include the price, and list the books in descending order by price. Within a group of books having the same price, further order the books by title.

这是我试图执行的查询:重复问题13,但也包括价格,并按价格降序列出书籍。在具有相同价格的一组书中,进一步按书名订购书籍。

Here is question 13: List the book code and book title of each book that has the type SFI, MYS, or HOR. Use the IN operator in your command.

这是问题13:列出具有SFI,MYS或HOR类型的每本书的书籍代码和书名。在命令中使用IN运算符。

Here is my SQL:

这是我的SQL:

SELECT BOOK_CODE, TITLE, PRICE
FROM BOOK
WHERE TYPE IN ('SFI', 'MYS', 'HOR')
ORDER BY PRICE DESC,
AND WHERE PRICE=PRICE
ORDER BY TITLE ASC;

1 个解决方案

#1


0  

You need to order by price first, then by title.

您需要先按价格订购,然后按标题订购。

Use this:

SELECT BOOK_CODE, TITLE, PRICE
FROM BOOK
WHERE TYPE IN ('SFI', 'MYS', 'HOR')
ORDER BY PRICE DESC, TITLE;

#1


0  

You need to order by price first, then by title.

您需要先按价格订购,然后按标题订购。

Use this:

SELECT BOOK_CODE, TITLE, PRICE
FROM BOOK
WHERE TYPE IN ('SFI', 'MYS', 'HOR')
ORDER BY PRICE DESC, TITLE;