在Sql中如何查找第二个交易日期 [英] In Sql How to find 2nd Transaction Date

查看:409
本文介绍了在Sql中如何查找第二个交易日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

2110060101092684    1500    2009    23/06/2010 12:00:00 AM  Tr from Rebate  96.0000 NULL    1   1   Pacs    Direct  NULL    17768   Transfer    147059  NULL    1092    96.0000 NULL    NULL    NULL    NULL    00031
2110060101092684    1500    2009    21/08/2010 12:00:00 AM  Transfer    NULL    450.0000    2   3   Pacs    Direct  20/08/2011 12:00:00 AM  17911   Transfer    99  NULL    1092    NULL    NULL    NULL    NULL    NULL    00031
2110060101092684    1500    2009    26/03/2011 12:00:00 AM  Cash    21914.0000  NULL    2   3   Pacs    Direct  NULL    19055   Cash    521849  125.0000    1092    20354.0000  1426.0000   9.0000  0.0000  NULL    00031
2110060101092684    1500    2009    30/03/2011 12:00:00 AM  Transfer    NULL    35000.0000  2   3   Pacs    Direct  29/03/2012 12:00:00 AM  19263   Transfer    64  NULL    1092    NULL    NULL    NULL    NULL    NULL    00031




提款后我需要在TransactionDate交易
如何编写查询




I need to after withdrawal amount TransactionDate Transactions
How to write the query

推荐答案

一种方法是这样的(如果transactiondate唯一定义了顺序):
One way to do this is something like (if transactiondate defines uniquely the order):
select *
from tablename tn
where 1 = (select count(*)
           from tablename tn2
           where tn2.transactionadate < tn.transactiondate)


那应该选择交易日期第二低的行.


That should select the row having the second lowest transaction date.


这篇关于在Sql中如何查找第二个交易日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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