Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/sql/70.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql 每个实例的最大日期/时间_Sql_Max - Fatal编程技术网

Sql 每个实例的最大日期/时间

Sql 每个实例的最大日期/时间,sql,max,Sql,Max,早上好: 我有这个查询,但我需要它给我每个订单的最后日期/时间。订单有时会在每个日期多次处理…我只想要最后一个实例。这是问题…任何帮助都将非常感谢…提前谢谢 SELECT dbo.fn_GetNotesForOrder(o.orderid) as Notes, o.OrderNumber, ss.statusname, max(oh.EntryDate), l.locationcode, l.locationname, a.street, a.city, a.province, a.

早上好: 我有这个查询,但我需要它给我每个订单的最后日期/时间。订单有时会在每个日期多次处理…我只想要最后一个实例。这是问题…任何帮助都将非常感谢…提前谢谢

SELECT      dbo.fn_GetNotesForOrder(o.orderid) as Notes, o.OrderNumber, ss.statusname, max(oh.EntryDate),  l.locationcode, l.locationname, a.street, a.city, a.province, a.postalcode, oh.UserID

FROM         orders as o
                               INNER JOIN
             OrderHistory as oh on o.OrderID = oh.OrderID
                               INNER JOIN 
             Statuses as ss on ss.StatusID = oh.Status
                               INNER JOIN   
             addresses as a on a.addressid = oh.addressid
                               INNER JOIN
             locations as l on l.locationid = a.locationid

             WHERE     (oh.EntryDate >= CONVERT(DATETIME, '2013-06-24 00:00:00', 102) AND oh.EntryDate < CONVERT(DATETIME, '2013-06-29 00:00:00', 102)) AND 
                      (UserID in ('MAXWELLPAPER\leyre'/*, 'MAXWELLPAPER\ndwyer', 'MAXWELLPAPER\jploeger', 'MAXWELLPAPER\jpquintanilla', 'MAXWELLPAPER\dwatkinson'*/))

             group by o.orderid, o.ordernumber, ss.statusname, l.locationname, l.locationcode, a.street, a.city, a.province, a.postalcode, oh.UserID, oh.entrydate
             order by oh.entrydate

任何人Tombom,我看不到添加的字符…谢谢…您可以使用秩或行数或子查询