Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7941923
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T23:48:47+00:00 2026-06-03T23:48:47+00:00

I need to list only the first five requests for companies from my database.

  • 0

I need to list only the first five requests for companies from my database. I have two tables named as Request and Company. There could be any amount of requests for a given company. But, I need to query and list only the first 5 requests of all the companies in my database.

select top 5 *
from Request as r 
    INNER JOIN Company c
    ON r.Company_id=c.Company_ID

I have done the above query but it is returning only the first five from the table not the first five of all members. How can I correct my query?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T23:48:49+00:00Added an answer on June 3, 2026 at 11:48 pm

    I think you’re looking for the top 5 requests for each company that exists in your Company table. In that case, you can rank() each request by company in a subselect and then select where the rank is <= 5:

    select company_id, request_id
    from
        ( select c.company_id, r.request_id, rank() over (partition by c.company_id order by request_id) as Rank
        from request r
        inner join company c on
            r.company_id = c.company_id
        ) ranked
    where rank <= 5
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a list of images that need to be displayed. However theres only
I have two lists. At start only the first one has visible elements, the
I have a column containing the list of names. I need to select only
I have two tables - incoming tours(id,name) and incoming_tours_cities(id_parrent, id_city) id in first table
I need to return from a list only those values which are odd so
I have two tables that I need to compare and update values in one
What do you do if you need to generate a read-only list of data
I need a list from OldGuids that are not in the NewGuids, so I
Maybe somebody could help me. I need a two methods. The first should open
Lets say we need to select two sets from a table: Things var GradeA

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.