根据日期获得记录

时间:2017-04-16 17:32:46

标签: sql-server date

我根据日期尝试此查询我根据当前日期在此记录中只有列datecurrent所以现在有近5天不同日期的记录我想根据日期获取记录我使用此但这显示所有记录而我希望在特定日期获得记录

   select c.Orderid,c.DateCurrent,c.Quantity,c.ItemCost,i.ItemCost*c.quantity 
as Bill from CustomerOrder c inner join item i on i.ItemId=c.ItemId 
inner join userinformation ui on ui.userid=c.userid 
where c.datecurrent as fromdate > '2017-04-13'  union all 
select null,null,null,null,sum (i.ItemCost*c.Quantity) bill
  from CustomerOrder c  inner join item i on i.itemid=c.ItemId
   inner join userinformation ui on ui.userid=c.userid where c.datecurrent as todate > '2017-04-15'

有16个日期及以上查询的记录显示16个日期记录,其中我只想要那些介于13和15之间且与其他日期相同的记录..我在winforms中使用datepicker尝试此查询

这是数据

 Orderid    DateCurrent Quantity    ItemCost    Bill
101 2017-04-16 14:35:45.823 12  10  120
1093    2017-04-16 17:32:36.250 2   10  20
2093    2017-04-16 17:32:36.250 2   10  20
2094    2017-04-13 17:32:36.250 4   10  400
2095    2017-04-15 17:32:36.250 5   10  50
2096    2017-04-15 17:32:36.250 10  10  1000
2097    2017-04-14 17:32:36.250 12  10  120
NULL    NULL    NULL    NULL    1210

如果我只输入13到15之间的日期,我想获取数据

Orderid DateCurrent Quantity    ItemCost    Bill
2094    2017-04-13 17:32:36.250 4   10  400
2095    2017-04-15 17:32:36.250 5   10  50
2096    2017-04-15 17:32:36.250 10  10  1000
2097    2017-04-14 17:32:36.250 12  10  120
NULL    NULL    NULL    NULL    1210

1 个答案:

答案 0 :(得分:1)

我怀疑这样做符合你的要求:

response:
{
  "data": [
    {
      "created_time": "2018-02-28T08:49:14+0000", 
      "id": "<LEAD_ID>", 
      "ad_id": "<AD_ID>",
      "form_id": "<FORM_ID>",
      "field_data": [
        {
          "name": "car_make",
          "values": [
            "Honda"
          ]
        }, 
        {
          "name": "full_name", 
          "values": [
            "Joe Example"
          ]
        }, 
        {
          "name": "email", 
          "values": [
            "joe@example.com"
          ]
        },
      ]
    }
  ],
  "paging": {
    "cursors": {
      "before": "OTc2Nz3M8MTgyMzU1NDMy", 
      "after": "OTcxNjcyOTg8ANTI4NzE4"
    }
  }
}

每个日期返回一行加上所有日期的总和,以及成本时间数量的总和。