Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Select
Message
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Title:
Select
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01140023
Message ID:
01140023
Views:
65
Tenho uma tabela que guarda o movimento de vários produtos por data :
ProdutoId Data             Qtd 
1         01/01/2006       100
1         02/01/2006        10
1         03/01/2006        50
2         02/01/2006         1
2         10/01/2006        20
Necessito de um comando T-SQL, que me retorne somente uma linha por ProdutoID, contendo a Data e Qtd da Maior data.

No exemplo Acima Seria
ProdutoId Data             Qtd 
1         03/01/2006        50
2         10/01/2006        20
Tentei fazer com Group by e Max de data, mas gerou um erro porque pede para que o Campo Qtd Também tenha a clausula group by, com isto acaba retornando todas as linhas do ProdutoId

Alguem poderia me ajudar nesta solução ?
Paulo Cesar Carneiro
desenvolvimento@controplan.com.br


"My God, what have we done?"
-- Capt. Robert Lewis, co-pilot of the Enola Gay, recalling the moment the atomic bomb exploded over Hiroshima

At 8:15 a.m. on August 6 1945
Next
Reply
Map
View

Click here to load this message in the networking platform