Ranking Seller Sum
1 Paul 2.212,00
2 Robert 1.500,00
3 ....
....
I have already the sql, but I dont know how to do the ranking number
column...
Can you help me?
Using VS 2005 and Sql Server 2000
Thanks !
Post the SQL you have and let us know what it is you need specifically
"Paulo" <prb...@uol.com.br> wrote in message
news:OXvdcfAD...@TK2MSFTNGP04.phx.gbl...
Sorry, I forgot...
Is there any way creating on the sql the column ranking with the number?
Thanks
"Just Me" <news.microsoft.com> escreveu na mensagem
news:%23QXrUoA...@TK2MSFTNGP02.phx.gbl...
change the type I put nvarchar(100) Null on all
DECLARE @Empresa TABLE (
ranknum int IDENTITY(1,1) NOT NULL PRIMARY KEY,
NOME_EMPRESA nvarchar(100) NULL,
VendedorNOME_VENDEDOR nvarchar(100) NULL,
NOME_PROMOTORnvarchar(100) NULL,
sumVL_CREDITO nvarchar(100) NULL
)
then populate the temp table with the rank
INSERT into @Empresa (NOME_EMPRESA,VendedorNOME_VENDEDOR
,NOME_PROMOTORnvarchar,sumVL_CREDITO)
Select Empresa.NOME_EMPRESA,Vendedor.NOME_VENDEDOR
NOME_PROMOTOR,Sum(CONTRATO.VL_CREDITO) VL_CREDITO
From Contrato,Empresa,Vendedor Where
CONTRATO.COD_EMPRESA=EMPRESA.COD_EMPRESA And
Contrato.COD_VENDEDOR=VENDEDOR.ID_VENDEDOR Group By
NOME_EMPRESA,NOME_VENDEDOR
Order by VL_CREDITO Desc
Finally
select * from @Empresa
"Paulo" <prb...@uol.com.br> wrote in message
news:%238vgq1A...@TK2MSFTNGP04.phx.gbl...
"IfThenElse" <sql_ag...@hotmail.com> wrote in message
news:OkP2u%23DDIH...@TK2MSFTNGP05.phx.gbl...
"rote" <naija...@hotmail.com> wrote in message
news:uGbgixGD...@TK2MSFTNGP05.phx.gbl...