SQL ?
am 11.10.2007 19:40:55 von PaulO
Hi, I need to create a ranking column wich will be the row number... it is
the seller wich most sells... example below:
NOME_EMPRESA Ranking NOME_PROMOTOR VL_CREDITO
EMPRESA 1 Paul
2.212,00
EMPRESA 2 Robert
1.500,00
EMPRESA 3 ....
"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";
Is there any way creating on the sql the column ranking with the number?
Or must I create a separated DataSet and manipulates/populating it ?
Thanks
Re: SQL ?
am 11.10.2007 20:19:33 von reb01501
Paulo wrote:
> Hi, I need to create a ranking column wich will be the row number...
> it is the seller wich most sells... example below:
>
> NOME_EMPRESA Ranking NOME_PROMOTOR VL_CREDITO
> EMPRESA 1 Paul
> 2.212,00
> EMPRESA 2 Robert
> 1.500,00
> EMPRESA 3 ....
>
>
> "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";
>
> Is there any way creating on the sql the column ranking with the
> number?
>
It depends on the database type and version.
> Or must I create a separated DataSet and manipulates/populating it ?
>
DataSet? Are you talking about ASP.Net? If so, you should follow up in
the dotnet group:
microsoft.public.dotnet.framework.aspnet.
There are also forums at www.asp.net where you can find a lot of people
to help you
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.
Re: SQL ?
am 11.10.2007 20:24:34 von PaulO
Using SQL Server 2000
Yes Im using .net, but if you tell me the only way is creating a second
RecordSet and populating it I do it via programming...
Just want to know if it is possible to be done via pure SQL...
Thanks man!
"Bob Barrows [MVP]" escreveu na mensagem
news:eHQeHNDDIHA.5160@TK2MSFTNGP05.phx.gbl...
> Paulo wrote:
>> Hi, I need to create a ranking column wich will be the row number...
>> it is the seller wich most sells... example below:
>>
>> NOME_EMPRESA Ranking NOME_PROMOTOR VL_CREDITO
>> EMPRESA 1 Paul
>> 2.212,00
>> EMPRESA 2 Robert
>> 1.500,00
>> EMPRESA 3 ....
>>
>>
>> "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";
>>
>> Is there any way creating on the sql the column ranking with the
>> number?
>>
>
> It depends on the database type and version.
>
>> Or must I create a separated DataSet and manipulates/populating it ?
>>
> DataSet? Are you talking about ASP.Net? If so, you should follow up in
> the dotnet group:
>
> microsoft.public.dotnet.framework.aspnet.
> There are also forums at www.asp.net where you can find a lot of people
> to help you
>
> --
> Microsoft MVP -- ASP/ASP.NET
> Please reply to the newsgroup. The email account listed in my From
> header is my spam trap, so I don't check it very often. You will get a
> quicker response by posting to the newsgroup.
>
>
Re: SQL ?
am 11.10.2007 20:46:22 von reb01501
Paulo wrote:
> Using SQL Server 2000
>
> Yes Im using .net, but if you tell me the only way is creating a
> second RecordSet and populating it I do it via programming...
>
> Just want to know if it is possible to be done via pure SQL...
>
Well, I'm not really sure why you don't use the ordinal position of the
datarow in the datatable, but ...
http://databases.aspfaq.com/database/how-do-i-return-row-num bers-with-my-query.html
--
Microsoft MVP -- ASP/ASP.NET
Please reply to the newsgroup. The email account listed in my From
header is my spam trap, so I don't check it very often. You will get a
quicker response by posting to the newsgroup.