473,320 Members | 1,876 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

top4 by bank

hi i need to do a query that selects the top 4 best for each bank so the result
would be like that

bank cod
1 2
1 3
1 4
1 5
2 6
2 7
2 9
2 15

plz give a help.
thanks
Jan 28 '08 #1
4 1056
deepuv04
227 Expert 100+
hi i need to do a query that selects the top 4 best for each bank so the result
would be like that

bank cod
1 2
1 3
1 4
1 5
2 6
2 7
2 9
2 15

plz give a help.
thanks

can u give clear explanation on what criteria you want to filter the data with example...
Jan 28 '08 #2
can u give clear explanation on what criteria you want to filter the data with example...
for example, i have bank 1, bank 2 and bank 3. these banks have several records of tax, etc. i would like to get the bank 1 top 4, the bank 2 top4 and the bank 3 top 4

select top 4 * from tb_banks where cod_bank = @cod_bank

this would return only for the @bank specified, what i want is the top 4 aggrouped by bank

thx
Jan 28 '08 #3
i ve found the answer, hope it helps

SELECT d.* FROM (
SELECT *, ROW_NUMBER()
OVER (PARTITION BY cod_banco,parcelas ORDER BY coeficiente asc) AS RecID FROM tb_valor_bancos
) AS d
inner join tb_bancos ban on
ban.cod_banco = d.cod_banco
WHERE RecID < 5 'here is the number of lines you want to show for each group
Jan 28 '08 #4
deepuv04
227 Expert 100+
i ve found the answer, hope it helps

SELECT d.* FROM (
SELECT *, ROW_NUMBER()
OVER (PARTITION BY cod_banco,parcelas ORDER BY coeficiente asc) AS RecID FROM tb_valor_bancos
) AS d
inner join tb_bancos ban on
ban.cod_banco = d.cod_banco
WHERE RecID < 5 'here is the number of lines you want to show for each group

ohh.. thats greate.. good logic
Jan 29 '08 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Stefan Reiter | last post by:
Hi, I am trying to validate bank numbers ( the number that identifies a bank) and bank account numbers. Is there a certain algorithm or do you know any generell rules like how long the...
1
by: Amos | last post by:
Dear Sirs I am trying to build a cash flow software, first I thought to build one table for each cash and bank account, but talking to some people they suggested me to build one unique table for...
5
by: bobdydd | last post by:
Hi Guys Can anyone help I am trying to find a way to implement a running balance that will re-calculate if the date order is changed, or if an earlier record is changed like you might want to do...
6
by: Thapliyal, Deepak | last post by:
Hi, Assume I have a bank app.. When customer withdraws $10 from his accouint I have to do following --> update account_summary table --> update account detail_table Requirement: either...
0
by: malcolm | last post by:
Bank Charges Refunded Free help to recover your bank or credit card charges from www.bankchargesrefunded.co.uk Its your money and its better in your pocket!
7
by: Artificer | last post by:
Is asp.net 2.0 appropriate to develop bank application or is intended for less usage intensive environment. Are there any bank application developed on it?
6
by: Jana | last post by:
Greetings Access Gurus! I am working on an app to send batch transactions to our bank, and the bank requires that we place an effective date on our files that is 'one business day in the future,...
3
by: alexquisi | last post by:
Hi, I am newbie in optimization techniques and I need a little of help. I want to take adventage of the open bank and open row policy available in the processor (it can keep 4 banks open per...
2
by: cheongsiwei | last post by:
Need some helps here >.< The project i required to complete : Create a base class Bank of a bank account with member functions to allow withdrawal, deposit and calculation of balance. ...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.