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 name
s 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 systemid
s that have remained stable across all snapshot
s (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!).