简体   繁体   中英

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). 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)!

SELECT YEAR, WRITER, TITLE ORDER BY YEAR, WRITER;

Something like this will sort by writer within year.

@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;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM