4
You can use the function Min
with the function of aggregation Group By
.
I used the Script below for tests:
CREATE TABLE [dbo].[TesteLetra](
[letra] [varchar](1) NULL,
[numero] [int] NULL
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
insert into TesteLetra (letra,numero) values
('A',1)
insert into TesteLetra (letra,numero) values
('B',2)
insert into TesteLetra (letra,numero) values
('C',1)
insert into TesteLetra (letra,numero) values
('D',1)
insert into TesteLetra (letra,numero) values
('D',2)
insert into TesteLetra (letra,numero) values
('D',3)
insert into TesteLetra (letra,numero) values
('E',3)
insert into TesteLetra (letra,numero) values
('E',4)
And my consultation was the following:
select letra,Min(numero) ValorMinimo from TesteLetra
Group By letra
Upshot:
This is softer than taking candy from a child. :)
– Marco Souza
It worked, thank you.
– Brupikk
@Brupikk good that I could help :), do not forget to mark it as correct because it can help other people too.
– Marconi
@Marconi without speaking that he earns 2 posts per accept :)
– Marco Souza