如何对表格进行排序 [英] How to sort the table

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

问题描述

我有一个像这样的表(表1):


col1 col2
1公羊
2假
3 ravi
4 mohit
5莫汉
6个subhash

我还有另一个查询结果(在临时表中:#tempo),它是:


subhash
ram
ravi
mohit
mohan


我希望按照表1中给出的顺序对结果进行排序.

我该怎么办..请帮助!谢谢.

I have a table(Table 1) like this :


col1 col2
1 ram
2 sham
3 ravi
4 mohit
5 mohan
6 subhash

and i have another query result(in temp table :#tempo) which is :

sham
subhash
ram
ravi
mohit
mohan


I want this resultant to be sorted in the sequence given in Table 1.

How do i do it .. PLease help !! it will be appreciated .Thanks in advance.

推荐答案

除非生成临时表时保留了col1值和col2值,否则-不容易.唯一的方法是从名称向原始col1进行反向引用,然后再次对其进行排序.除非名称也唯一,否则这将无效.

我将修改临时表以包含col1并仅使用ORDER BY-这要容易得多,并且处理器效率也要高得多.
Unless you have retained the col1 value with your col2 value when you generated your temp table, you can''t - not easily. The only way to do it would be to backreference from the name to the original col1 and sort by that again. Which won''t work unless the names are also unique.

I would modify my temp table to include the col1 and just use ORDER BY - it''s a lot easier, and a lot more processor efficient.


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

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