结果会是什么? [英] What will be the result ?

查看:49
本文介绍了结果会是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  SELECT   TOP   1  *  FROM  table_Name  ORDER   BY  unique_column  DESC  





会有什么结果:

- 最后插入一个或

- 第一个?



我需要最后插入的CustomerID。

解决方案

查询解释了自己,它返回 table_Name 的整个顶行,按 unique_column排序,降序。这样,您将获得具有最大值 unique_column 的行。如果您逐步插入 unique_column ,您将获得最后一个插入的。



出于好奇,为什么不尝试呢?


最后插入一个将是你的输出


< blockquote>



检查这个...



订购者 [ ^ ]



希望这对您有所帮助。





干杯


SELECT TOP 1 * FROM table_Name ORDER BY unique_column DESC



What will be the result:
- last inserted one or
- first one ?

I need last inserted CustomerID.

解决方案

The query explains itself, it returns the whole top row of table_Name ordered, descending, by unique_column. This way you'll get the row having the greatest value of unique_column. If you are inserting unique_column incrementally then, yes, you'll get the last inserted one.

Out of curiosity, why don't you try it?


last inserted one will be your output


Hi,

Check this...

Order By[^]

Hope this will help you.


Cheers


这篇关于结果会是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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