c# - LINQ to SQL - selecting a list of the highest version numbers -


I am trying to write some linux to SQL which will bring me back to the list of rows, in which an instance of the basacquenites , But I want the row with the highest version, therefore, from the following table of data:

  Id was created Version Version BaseQuestionID 2 2009-10-07 13:47 47: 27.687 1 2 3 2009-10-07 13:49 49: 35.010 1 3 4 2009-10-09 16: 03: 45.973 1 5 5 2009-10-16 16: 01: 33.603 2 5 6 2009-10-16 16:16-16: 22.680 1 6 7 2009-10-16 16: 16: 53.807 2 6 8 2009-10-16 16: 41: 31.180 3 6 9 2009-10-19 08: 06: 23.210 4 6  

I have to go back:

  created id version version BaseQuestionID 2 2009-10-07 13:47 47: 27.687 1 2 3 2009-10-07 13:49 49: 35.010 1 3 5 2009-10-16 16:01: 33.603 2 5 9 2009-10-19 08: 06: 23.210 4 6 I have tried many things, but so far It has not been dismissed. I am working in vb.net, but am trying and translating from c # if you know it ... any indicator will be highly appreciated.   

How about (C #):

  in q Q. Q. For q.BaseQuestionID grouped group group by Q group q. OrderbyWindingSending (q = & gt; Q.Version). First ()  

So you basically create groups of rows by the question id:

  Id created version version BaseQuestionID 2 2009-10-07 13: 47: 27.687 1 2 3 2009-10-07 13:49 49: 35.010 1 3 4 2009-10-09 16: 03: 45.973 1 5 5 2009-10-16 16: 01: 33.603 2 5 6 2009-10 -16 16: 16: 22.680 1 6 7 2009-10-16 16: 16: 53.807 2 6 8 2009-10-16 16:41 41: 31.180 3 6 9 2009-10-19 08: 06: 23.210 4 6 Code>  

(each block is a "grouped line") and then descending by order of each live version, taking only the first row:

  created the id Date number Version BaseQuestionID 2 2009-10-07 13: 47: 27.687 1 2 3 2009-10-07 13:49 49: 35.010 1 3 5 2009-10-16 16: 01: 33.603 2 5 9 2009-10-19 08: 06 : 23.210 4 6  

I hope get a sensible translation in SQL, but I definitely would not want to say :)


Comments

Popular posts from this blog

asp.net - Javascript/DOM Why is does my form not support submit()? -

sockets - Delphi: TTcpServer, connection reset when reading -

javascript - Classic ASP "ExecuteGlobal" statement acting differently on two servers -