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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T01:51:50+00:00 2026-05-14T01:51:50+00:00

I have a table containing some names and their associated ID, along with a

  • 0

I have a table containing some names and their associated ID, along with a snapshot:

snapshot, systemid, name[, some, other, columns]

I need to identify all the unique names that a systemid has had across all snapshots, but only where there has been at least once change.

For example, with the data:

'DR1', 0, 'MOUSE_SPEED'
'DR1', 1, 'MOUSE_POS'
'DV8', 0, 'MOUSE_BUTTONS'
'DV8', 1, 'MOUSE_POS'
'DR6', 0, 'MOUSE_BUTTONS'
'DR6', 1, 'MOUSE_POS'
'PP2', 0, 'MOUSE_SPEED'
'PP2', 1, 'MOUSE_POS'

…I’d like a query that will return (in any order):

0, 'MOUSE_SPEED'
0, 'MOUSE_BUTTONS'

Additionally, it would be useful to have the inverse – a list of systemids that have remained stable across all snapshots (that is, where the name has never changed).

I am using PostgreSQL v8.4.2.

EDIT: Updated to reflect comments (sorry for the original less-than-perfect post, I am new here!).

  • 1 1 Answer
  • 2 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-05-14T01:51:51+00:00Added an answer on May 14, 2026 at 1:51 am

    Following is with SQL Server but it does not use any SQL Server specific constructs. It should be portable to postgresql.

    SQL Statement

    SELECT  DISTINCT t1.id, t1.name
    FROM    @Table t1
            INNER JOIN (
              SELECT  t.id 
              FROM    (
                        SELECT  DISTINCT id, name
                        FROM    @Table
                      ) t
              GROUP BY t.id 
              HAVING COUNT(*) > 1
            ) t2 ON t2.id = t1.id
    

    Test data

    DECLARE @Table TABLE (snapshot INTEGER, id INTEGER, name VARCHAR(32))
    
    INSERT INTO @TABLE
    SELECT 1, 0, 'MOUSE_SPEED'
    UNION ALL SELECT 1, 1, 'MOUSE_POS'
    UNION ALL SELECT 1, 2, 'KEYBOARD_STATE'
    UNION ALL SELECT 2, 0, 'MOUSE_BUTTONS'
    UNION ALL SELECT 2, 1, 'MOUSE_POS'
    UNION ALL SELECT 2, 2, 'KEYBOARD_STATE'
    UNION ALL SELECT 3, 0, 'MOUSE_SPEED'
    UNION ALL SELECT 3, 1, 'MOUSE_POS'
    UNION ALL SELECT 3, 2, 'KEYBOARD_STATE'
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table containing some Timespans (as two TIME columns) Eg: TimeBegin TimeEnd
I have a favorite table containing some fields like login_id,driver_id(One login_id may have many
I have a table containing data about some users. Many of them use our
I have a table, containing rows, contaning cells - and some of them contain
I have a class containing Enum with values. (names) In other class I would
We have a SQL Server table containing Company Name, Address, and Contact name (among
At my workplace we have a database with multiple schemas, and some table names
I have a datatable containing system profile names. This table is then assigned as
I have a table containing some categories Categories Table: -- category_id <-- primary key
I have a number of tables containing some basic (business related) mapping data. What's

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.