我有一个表格,我们可以在其中有多个条目的相同票号。我想根据 Initiated on 列检索最近的票号(相同票号)。
Ticket VendorTicket InitiatedOn Comments
198165 test 2012-08-10 16:31:33.707 test
199485 sagar 2012-08-11 12:36:25.720 sagar
199485 sagar1 2012-08-11 14:36:25.720 sagar1
199478 kishor 2012-08-11 12:37:21.923 kishor
我已经在存储过程中用 T-SQL 编写了这个查询它给了我错误说xObj = {"Incorrect syntax near '.'."}
我的 T-SQL
`@SQL='Select ''<a href="javascript:editTicketByIDAction('' + CONVERT(VarChar(Max), Ticket) + '')">'' + CONVERT(VarChar(Max),Ticket) + ''</a>'' t1.Ticket,t1.VendorTicket[Vendor Ticket],t1.Comments
From VendorTickets t1
WHERE NotifyOn <= GetDate() And NotifyOn Is Not Null AND
NOT EXISTS
(SELECT * FROM VendorTickets t2
WHERE t1.Ticket = t2.Ticket AND t1.InitiatedOn < t2.InitiatedOn)'`