Results 1 to 2 of 2
  1. #1
    Join Date
    Oct 2010
    Posts
    1

    Unanswered: 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?

  2. #2
    Join Date
    Sep 2010
    Location
    Germany, Brunswick
    Posts
    55
    I tried some stuff and I dont find a way,

    Is it possible to use/create Stored Procedures?
    WilhelmW

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •