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 7948007
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T01:35:50+00:00 2026-06-04T01:35:50+00:00

I have three tables: Table 1 – Members Id Name 1 Member1 2 Member2

  • 0

I have three tables:

Table 1 – Members

Id   Name
1    Member1
2    Member2

Table 2 – Activity

Id   Member_id   Activity    Date
 1      1        Activity1   2001-1-1
 2      1        Activity2   2001-2-1
 3      1        Activity3   2001-3-1
 4      2        Test        2010-4-1

Table 3 – Detailed

Id  Activity_id Information
1   2       Information

From the following, the Member id 1 has three activities:

SELECT Member.id, COUNT(*) AS number
FROM Member 
INNER JOIN Activity ON Activity.Member_ID = Member.id
GROUP BY Member.id

My question is how I can find the id and date of the second activity (table 2) for all Members from table(1) who has 2 activities and also retrieve the information related to this activity id from table 3.

Thanks in advance

  • 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-04T01:35:52+00:00Added an answer on June 4, 2026 at 1:35 am

    Row number function would help you here.

    select *
    from (
        select 
            *,
            rn = row_number() over (partition by member_id order by id)
        from
            activity
    ) activityWithRn
    inner join detailed on detailed.activity_id = activityWithRn.id
    where activityWithRn.rn = 2
    

    Here I’ve partitioned the data by member id and the ordered the activity by its id but maybe you want to order by date?

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have three tables like this: Person table: person_id | name | dob --------------------------------
I have three tables, Name - columns Custpackingslipjour(table 1) - (deliverydate, dateclosed,, salesid) Inventrans
I have this three tables: products TABLE: id:integer name:string features TABLE: id:integer name:string features_products
I have three tables. First table is Activities and second is Members and last
I have three tables, table one (tableA) containing users data like name and email,
I have three tables: Employee(Id,name etc) Appointment(Id,date,time,employee id, clientid etc) Client(Id,name etc) The Employee
I have three tables: CREATE TABLE person (id int, name char(50)) CREATE TABLE eventtype
I have three tables table name: tags id (int) tag_name (vharchar) table name: messages
So I have three tables: Table Place: _id autoincrement not null primary key, name
Say I have these three tables: Table: Baskets id | name 1 Sale 2

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.