I have been trying to solve this for about a week now. I really need someone's help.
I will be given two or three "LN"s and I have to check if they have the same number in the column "FODEX". Then maybe just add a column and print one if they have the same FODEX, and print zero if not.
I wrote this query:
SELECT MSTR.LN , LINK.SEQNO, MMA5_MSTR.FODEX, MMA5_MSTR.DES, MSTR.SL
FROM (((MSTR INNER JOIN LINK
ON MSTR.SEQNO = LINK.SEQNO) INNER JOIN MMA5_MSTR
ON LINK.FODEX = MMA5_MSTR.FODEX))
WHERE (MSTR.LN LIKE "%NOVOLLL%" OR MSTR.LN LIKE "%TRES%" OR MSTR.LN LIKE
"%ENBREL%")
GROUP BY SEQNO, SL
ORDER BY FODEX;
This is the output I get,
LN || SEQNO || FODEX || DES || SL
----------------------------------------------------------------
TRES || 71842 || 13 || ANTIDIABE || 12
NOVOLLL || 44340 || 13 || ANTIDIABE || 12
NOVOLLL || 44340 || 1059 || ANTIDIABE || 55
TRES || 71842 || 1059 || ANTIDIABE || 55
TRES || 71842 || 1317 || ANTIDIABE || 66
NOVOLLL || 44340 || 1317 || ANTIDIAB || 66
ENBREL || 40869 || 1722 || TNe || 90
ENBREL || 40869 || 29359 || IMMUNOSUPP || 103
This is the output I am trying to get,
LN || SEQNO || FODEX || DES || SL || Y/N
----------------------------------------------------------------
TRES || 71842 || 13 || ANTIDIABE || 12 || 1
NOVOLLL || 44340 || 13 || ANTIDIABE || 12 || 1
NOVOLLL || 44340 || 1059 || ANTIDIABE || 55 || 1
TRES || 71842 || 1059 || ANTIDIABE || 55 || 1
TRES || 71842 || 1317 || ANTIDIABE || 66 || 1
NOVOLLL || 44340 || 1317 || ANTIDIAB || 66 || 1
ENBREL || 40869 || 1722 || TNe || 90 || 0
ENBREL || 40869 || 29359 || IMMUNOSUPP || 103|| 0