I have a table in DB2 (oracle syntax) looking like this, let's call it SAMPLE
ID TAG_NAME VALUE
13 10 77
13 11 80
14 10 92
14 11 83
What I want to do is select all rows where TAG_NAME 10 has VALUE 77 and TAG_NAME 11 has VALUE 80. How can I do this? If I do like below it will try to create a situation where the TAG_NAME has to be both 10 and 11, while the VALUE has to be both 77 and 80. I don't want to select these specific tag names, rather when the tag name is x then it should check that the value is y etc.
SELECT
*
FROM
SAMPLE
WHERE
(TAG_NAME=10 AND VALUE=77)
AND (TAG_NAME=11 AND VALUE=80)
The result I want to achieve is this:
ID TAG_NAME VALUE
13 10 77
13 11 80