If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Informix > selecting first 5 col1 but grouped by another col?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 10-05-10, 12:20
christiang christiang is offline
Registered User
 
Join Date: Oct 2010
Posts: 1
selecting first 5 col1 but grouped by another col?

Hi,

I'am new to informix and new to this forum. I am googling since two days and did read many pages in this forum but didn't find the solution for my problem:

Given is the table

country custname quantity
A aaa 1000
A bbb 900
A ccc 800
A ddd 700
A eee 600
B zzz 2000
B aaa 1900
B ggg 1800
B ttt 1700
B bbb 1600
B kkk 1500
B rrr 1400
CH aaa 3000
CH hhh 300
CH uuu 100
CH nnn 150
F ooo 1000
F aaa 200
F iii 100

I want to select the top 3 (quantity) for each country with one select.

The output shall look like this:

Country customer quantity
A aaa 1000
A bbb 900
A ccc 800
B zzz 2000
B aaa 1900
B ggg 1800
CH aaa 3000
CH hhh 300
CH nnn 150
F ooo 1000
F aaa 200
F iii 100

Who can help me?
Reply With Quote
  #2 (permalink)  
Old 10-06-10, 17:44
InformixWilli InformixWilli is offline
Registered User
 
Join Date: Sep 2010
Location: Germany, Brunswick
Posts: 52
I tried some stuff and I dont find a way,

Is it possible to use/create Stored Procedures?
__________________
WilhelmW
IBM Certified Database Associate

wilhelmw.de - www.isr.de
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On