[英]SQL query (Sort by multiple columns)
I have a problem writing a specific query for my database I have a table with the following records: 我在为数据库编写特定查询时遇到问题,我有一个包含以下记录的表:
[ID(PK),Writer,Title,Year,Description]
. 。 I want to sort the records first per year and secondly per Writer for every Starting Letter(AZ).
我想每年对记录进行排序,然后对每个作家的每个起始字母(AZ)进行排序。 So Have a result as this
所以有这样的结果
Year Writer Title
1999 A1 X
1999 A1 Y
2001 A2 V
2002 A1 Z
1991 B1 P
2002 B2 Q
2003 B1 R
So at the end will be years at ASC form for every Letter of the Alphabet (Writer ASC)! 因此,对于每个字母(作家ASC),将以ASC形式结束数年!
SELECT YEAR, WRITER, TITLE ORDER BY YEAR, WRITER;
按年份,作者,标题选择年份;
Something like this will sort by writer within year. 这样的事情将在一年之内按作者排序。
@Larz Plutzin.. @Larz Plutzin ..
he want the record to be sort first by author then by year. 他希望记录首先按作者分类,然后按年份分类。 check what he posted..
检查他发布的内容。
your query going to be like - may be he could not explain the written what he wants. 您的查询将是-可能是他无法解释他想要的书面内容。 but the result he wanted going to be like this only..
但是结果他只想变成这样。
SELECT YEAR, WRITER, TITLE ORDER BY WRITER, YEAR;
按年份选择年份,标题,标题顺序;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.