R
R
redcircle2019-12-25 19:02:21
SQL
redcircle, 2019-12-25 19:02:21

How to find different values ​​in SQL table?

There is a table in Sqlite with such columns: domain, key, value
domain can only take the values ​​"first" and "second".
You need to find such pairs of strings in which
a) the key was the same
b) one string in the pair domain == "first", the second domain == "second"
c) value would be different
(There was an idea to use the aggregate function "standard deviation ”, but sqlite3 does not have it)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rsa97, 2019-12-25
@redcircle

SELECT *
  FROM `table` AS `t1`
  JOIN `table` AS `t2`
    ON `t2`.`key` = `t1`.`key`
      AND `t1`.`domain` = 'первый'
      AND `t2`.`domain` = 'второй'
      AND `t2`.`value` != `t1`.`value`

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question