Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Select
Message
De
26/07/2006 09:50:07
Erick Miranda
Formata Data Business - Grupo Linx
Contagem, Brésil
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Base de données, Tables, Vues, Index et syntaxe SQL
Titre:
Re: Select
Versions des environnements
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Divers
Thread ID:
01140023
Message ID:
01140168
Vues:
17
This message has been marked as the solution to the initial question of the thread.
Olá Paulo,

Testa aí:
SELECT *;
	FROM minhaTabela tab1;
	WHERE data In 	(SELECT MAX(data);
				FROM minhaTabela tab2;
				GROUP BY ProdutoId;
				WHERE tab2.ProdutoId = tab1.ProdutoId;
			)

>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 ?
Erick
Força Sempre!
Strength Always!
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform