jcbiker Posted June 25, 2012 at 03:37 PM Report Share #465392 Posted June 25, 2012 at 03:37 PM 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 at 10:10 AM Report Share #465572 Posted June 26, 2012 at 10:10 AM 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 at 12:22 PM Author Report Share #465587 Posted June 26, 2012 at 12:22 PM Ok. Link to comment Share on other sites More sharing options...
jcbiker Posted June 26, 2012 at 04:54 PM Author Report Share #465730 Posted June 26, 2012 at 04:54 PM (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 at 05:15 PM by Caça Link to comment Share on other sites More sharing options...
Caça Posted June 26, 2012 at 05:15 PM Report Share #465737 Posted June 26, 2012 at 05:15 PM 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 at 06:44 AM Author Report Share #465823 Posted June 27, 2012 at 06:44 AM (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 at 08:27 AM by Caça Link to comment Share on other sites More sharing options...
Caça Posted June 27, 2012 at 08:26 AM Report Share #465828 Posted June 27, 2012 at 08:26 AM 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 at 10:08 AM Author Report Share #465876 Posted June 27, 2012 at 10:08 AM (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 at 10:14 AM by Caça Link to comment Share on other sites More sharing options...
Caça Posted June 27, 2012 at 10:14 AM Report Share #465881 Posted June 27, 2012 at 10:14 AM 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 at 10:59 AM Author Report Share #465894 Posted June 27, 2012 at 10:59 AM Ok. vou tentar Obrigado Link to comment Share on other sites More sharing options...
jcbiker Posted June 27, 2012 at 12:24 PM Author Report Share #465917 Posted June 27, 2012 at 12:24 PM 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