需要重新排序表格! [英] Need to reorder a table!

查看:83
本文介绍了需要重新排序表格!的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用SELECT语句为朋友的表中的列表重新排序

该表如下所示:

Hi I need to reorder a list in a table for a friend using a SELECT statement

The table looks like this:

Region    Contact
---------------------
Cape Town        Fred
Cape Town        Joe
Cape Town        Anna
Durban           John
Durban           Mary
Johannesburg     Frank



它需要看起来像这样:



It needs to look like this:

Region    Contact
---------------------
Durban          John
Durban          Mary
Johannesburg    Frank
Cape Town       Anna
Cape Town       Fred
Cape Town       Joe


推荐答案

与导师成为朋友真是太好了. :)
由于您没有逻辑上的数据排序依据,因此您可以正确地执行排序依据,除非您忽略了表中的另一列以向我们显示.
但是,您可以检查UNION语句作为执行此操作的一种可能方法.
It is good that you are friends with your instructor. :)
Since you have no logical basis for ordering the data then you are correct that an order by will not work, unless there is another column in the table that you have neglected to show us.
You could examine the UNION statement as a possible way to do this, though.


Marcus的回答非常好!
要对表进行排序",您需要使用如下查询:
Marcus answer is very good!

To "sort a table" you need to use query like this:
SELECT Region, Contact
FROM YourTable
ORDER BY Region, Contact


这篇关于需要重新排序表格!的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆