ms access - selecting distinct pairs of values in SQL -


i have access 2010 database stores ip addresses of source , destination machines. if have following entries in database

 |source           |   destination| |--------------------------------| |               |     b        | |  b              |            | |               |     b        | |  c              |     d        | |  d              |     d        | 

is there query select unique pairs? is, output of query should be

 |source           |     destination| |----------------------------------| |               |          b     | |  c              |          d     | 

your question seems imply 2 things:

  1. when listing source/destination pairs want see pairs in 1 direction, e.g., (a,b) not (b,a).

  2. the list should omit pairs source , destnation same, e.g., (d,d)

in case query...

select distinct source, destination     (             select source, destination             sometable         union             select destination, source             sometable     ) source < destination 

...when run against [sometable] containing...

source  destination ------  -----------       b           b                       b           c       d           d       d           e       d           

...will produce:

source  destination ------  -----------       b           c       d           d       e           

Comments

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -