按输入的最后一列排序 [英] order by the last column entered

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

问题描述

大家好,

我有一个已输入数据的表.

这些列之一是日期.

我想选择已输入数据的最后一列.

有人可以帮我吗?
谢谢

Hi all,

I have a table that has entered data.

One of the these columns is the date.

I want to select the last column of data that has been entered.

Can any one help me?
Thanks

推荐答案

尝试:
SqlConnection con = new SqlConnection(connectionString);
con.Open();
SqlCommand com = new SqlCommand("SELECT * FROM myTable ORDER BY date DESC", con);
SqlDataReader r = com.ExecuteReader();
if (r.Read())
    {
    Console.WriteLine((DateTime) r["date"]);
    }
r.Dispose();
com.Dispose();
con.Dispose();

"ORDER BY"和"DESC"部分告诉它以特定顺序返回行(在本例中为日期"列),并以最新的优先顺序返回.

The "ORDER BY" and "DESC" parts tell it to return the rows in a specific order (in this case by the "date" column) with the newest first.


有我的灵魂

there is my soulation

<br />
SELECT TOP 1 *<br />
FROM TableName<br />
ORDER BY date DESC<br />



谢谢



thanks


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

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