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

  • SEARCH
  • Home
  • 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 8951155
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T13:35:49+00:00 2026-06-15T13:35:49+00:00

I am growing desperate over this problem: I have a table with just 3

  • 0

I am growing desperate over this problem:
I have a table with just 3 columns, each a reference to an ID of either a member or a journey.

create table sharesRoom (
 member1 int references Members,
 member2 int references Members,
 journey int references Journeys,
 primary key (member1,member2,journey));

I want to write a PLPGSQL function, that raises a notice with the information who has shared a room with whom and how often. For that notice it doesn’t matter in what succession the members are stored in the table. So this table

1 2 1
2 1 2
3 4 1
4 3 1
5 6 1
8 7 1

should raise this in a notice:
member1 member2 count( how often they shared a room )

1 2 2
3 4 1 (same journey, so this is just 1)
5 6 1
8 7 1

As you see, the order of the member columns doesn’t matter.

How is the best way to solve this? I have to admit, I don’t even know what to put in the select statement 🙁

  • 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-15T13:35:50+00:00Added an answer on June 15, 2026 at 1:35 pm

    You need a way of filtering out the ‘duplicates’ where the same members are just in a different order. One way to do this is with greatest and least:

    select high_member, low_member, count(*)
    from( select distinct greatest(member1, member2) as high_member, 
                          least(member1, member2) as low_member, 
                          journey 
          from sharesRoom )
    group by high_member, low_member
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have been writing a growing code base in Haskell. My problem is that
I have a form with an ever-growing amount of associated javascript. At present this
I have a page that have a growing number of images. Just like a
I have an analytics table (5M rows and growing) with the following structure Hits
I have a table with ~30 million rows ( and growing! ) and currently
I have a MySQL database with a growing number of users and each user
I have a growing website with around 30k images in 4 sizes for a
I have a growing application with multiple usercontrols, windows, etc that all send a
I have one database whose size is growing very fast. Curruntly its size is
Hi is it possible to have a JLabel text growing to the right instead

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.