最佳匹配查询和按列排序 [英] Best match query and order by columns

查看:70
本文介绍了最佳匹配查询和按列排序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我正在努力克服这种情况,我必须搜索4-5列并根据匹配的值在订单中生成结果这些专栏。


示例:

展开 | 选择 | Wrap | 行号

解决方案

选项1:

总是有CURSOR。但它可能很慢。


选项2:

这个只适用于SQL 2005及以上版本。

展开 | 选择 | Wrap | 行号


我是这样做的。

因为我们只有一行,所以我们有最接近的匹配humungus查询不会很慢

展开 | 选择 | Wrap | 行号


您好Delerna,


哇!我真的是这个意思。


非常感谢你帮我解决了这个糟糕的问题。事实证明它实际上比我想象的要大得多,但结果是最佳的。


我无法找到帮助你的话语,因为我徒劳无功圆形和某个地方或者其他东西都错过了。


现在,我会尝试让这个BIG查询有点动态,因为我的表中的列数根据要求不断变化。有时他们可能是3,有时是6,有时是4。


再次感谢。


我真的很感激你自己服用是时候帮我了。


Ankit Mathur



这是我怎么做的

因为我们只有一行,所以我们有最接近的匹配,humungus查询不会很慢

展开 | 选择 | Wrap | 行号

Hi,

I''m trying to overcome a situation whereby I have to search through 4-5 columns and produce the results with an order by according to the values matched in these columns.

Example:

Expand|Select|Wrap|Line Numbers

解决方案

Option 1:
There''s always CURSOR. It could be slow, though.

Option 2:
This one will work in SQL 2005 and up ONLY.

Expand|Select|Wrap|Line Numbers


Here is how I did it
Since we are working with only 1 row once we have the closest match the humungus query won''t be slow

Expand|Select|Wrap|Line Numbers


Hi Delerna,

WOW! and I really mean it.

Thank you so much for helping me with this humungous query. It actually turned out to be much bigger than I thought it would be but the result is optimal.

I am unable to find words to help you as in my vain attempts I was literally going round n round and somewhere or, the other something got missed out.

Now, I''ll try and get this BIG query to be somewhat dynamic as the number of columns in my table keeps changing according to requirements. Sometimes they could be 3 and sometimes 6 and another time 4.


Thanks once again.

I really appreciate yourself taking time to help me out.

Ankit Mathur


Here is how I did it
Since we are working with only 1 row once we have the closest match the humungus query won''t be slow

Expand|Select|Wrap|Line Numbers


这篇关于最佳匹配查询和按列排序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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