jcbiker Posted June 25, 2012 Report Share Posted June 25, 2012 Boa tarde, Tou a fazer uma aplicação ligada a uma base e necessito de saber como posso fazer para saber qual o maximo valor de uma determinada pesquisa. eu estou a utilizar este código Using Context As New viatEntities2 Dim esquadr = Context.Relatório.Where( Function(c) c.Id = dt). Link to comment Share on other sites More sharing options...
Caça Posted June 26, 2012 Report Share Posted June 26, 2012 Para isso usa a função MAX() Pedro Martins Não respondo a duvidas por PM Link to comment Share on other sites More sharing options...
jcbiker Posted June 26, 2012 Author Report Share Posted June 26, 2012 Ok. Link to comment Share on other sites More sharing options...
jcbiker Posted June 26, 2012 Author Report Share Posted June 26, 2012 (edited) Eu estou a fazer assim: Module Pesq Sub PesqT(ByVal dt, ByRef DtR, ByRef T, ByRef K) Dim ano As Date = Date.Today Using Context As New viatEntities2 Dim esquadr = Context.Relatório.Max.KmFim( Function(c) c.IdMatViat = dt And c.Data = ano) If esquadr IsNot Nothing Then End If End Using End Sub End Module Mas dá erro nesta linha Context.Relatório.Max.KmFim Edited June 26, 2012 by Caça Link to comment Share on other sites More sharing options...
Caça Posted June 26, 2012 Report Share Posted June 26, 2012 Vê isto http://msdn.microsoft.com/en-us/vstudio/bb737904#maxsimp Pedro Martins Não respondo a duvidas por PM Link to comment Share on other sites More sharing options...
jcbiker Posted June 27, 2012 Author Report Share Posted June 27, 2012 (edited) mas assim como é que faço a ligação a base? eu estou a utilizar este codigo Using Context As New viatEntities2 Dim categories = From p In products _ Group p By p.Category Into Group _ Edited June 27, 2012 by Caça Link to comment Share on other sites More sharing options...
Caça Posted June 27, 2012 Report Share Posted June 27, 2012 Qual é o campo que queres fazer o MAX? Pedro Martins Não respondo a duvidas por PM Link to comment Share on other sites More sharing options...
jcbiker Posted June 27, 2012 Author Report Share Posted June 27, 2012 (edited) O campo é este kmfim eu já tentei assim, Dim pq = From p In Relatório _ Select max.kmfim Where (Function(p) p.idmatViat = dt And p.data = ano) mas não funciona. ou seja eu queria o valor maximo de km deste campo com aquelas condicões Edited June 27, 2012 by Caça Link to comment Share on other sites More sharing options...
Caça Posted June 27, 2012 Report Share Posted June 27, 2012 Tenta assim Dim pq = From p In Relatório _ Where p.idmatViat = dt And p.data = ano _ Group p By p.KmFim Into Group = Group.Max(Function(p) p.KmFim) Pedro Martins Não respondo a duvidas por PM Link to comment Share on other sites More sharing options...
jcbiker Posted June 27, 2012 Author Report Share Posted June 27, 2012 Ok. vou tentar Obrigado Link to comment Share on other sites More sharing options...
jcbiker Posted June 27, 2012 Author Report Share Posted June 27, 2012 ainda me dá erro. diz que espera o fim da espressão. Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now