根据日期过滤结果

时间:2017-07-14 17:48:05

标签: sql sql-server

我有4列的查询结果,第3列是epoch unix时间的日期。该查询采用日期参数,例如'7/1/2017'

我想要做的是选择输入日期之前的记录,但可能有两个集合都有未来的日期。我想要最近的约会。

因此,在下面的示例中,日期为“1533013200000”的leaseCode“EDM09GW”将是更接近7/1/2017的日期

我不想记录EDM09GW |结果集中为1690779600000。

非常感谢任何帮助。

LeaseCode|BaseAmount      |ExpDate        |PaymentType
---------|----------------|---------------|-----------------
COR01GW  |-2.249938000000 | 1519797600000 | HST / PST Contra
COR01GW  |-1.125092000000 | 1519797600000 | GST Contra
COR01GW  | 1.125092000000 | 1519797600000 | GST (5%)
COR01GW  | 2.249938000000 | 1519797600000 | HSTNL
COR01GW  | 25.875154000000| 1519797600000 | Base
EDM01CL  |-1.740542000000 | 1540962000000 | GST Contra
EDM01CL  | 1.740542000000 | 1540962000000 | GST (5%)
EDM01CL  | 3.885136000000 | 1540962000000 | Realty Tax
EDM01CL  | 13.238843000000| 1540962000000 | Op Costs
EDM01CL  | 19.425027000000| 1540962000000 | Base
EDM09GW  |-2.429500000000 | 1533013200000 | GST Contra
EDM09GW  | 2.429500000000 | 1533013200000 | GST (5%)
EDM09GW  | 8.169002000000 | 1533013200000 | Realty Tax
EDM09GW  | 9.250506000000 | 1533013200000 | Op Costs
EDM09GW  | 33.600000000000| 1533013200000 | Base
EDM09GW  |-2.429500000000 | 1690779600000 | GST Contra
EDM09GW  | 2.429500000000 | 1690779600000 | GST (5%)
EDM09GW  | 8.169002000000 | 1690779600000 | Realty Tax
EDM09GW  | 9.250506000000 | 1690779600000 | Op Costs
EDM09GW  | 33.600000000000| 1690779600000 | Base

我的预期结果是只有EDM09GW | 1533013200000列和 EDM09GW | 1690779600000

0 个答案:

没有答案