I have a query which will always display amounts on 2 seperate rows. Which i would like to merge together into 1 row. The complication of this is that 1 of the queries may return nothing.
SELECT amount
FROM TABLE a
WHERE REFERENCE IN(1,2)
RETURNS 2 rows. I need the above to display my answer as 1 row;
amount (ref1), amount (ref2).
The following does combine and give me what i want. However, if one of the queries does NOT return anything from the database then nothing is returned. I need it always to return something. (There will always be 1 query that will return something).
What i have so far which is not quite right;
SELECT * FROM(
SELECT amount
FROM Table a
WHERE REFERENCE = 1) A
(SELECT amount
FORM Table b
WHERE REFERENCE = 2)B
This does return what i need. However, if i amend the query for one of the select statements to say reference 3 which does not exist. Nothing is returned. I would still want reference 1 returned and null for the second query.
Requre outputs;
1, 1
1, null
null, 1
null, null will never occur.
Any help would be appreciated.
Thanks in advance
SELECT amount
FROM TABLE a
WHERE REFERENCE IN(1,2)
RETURNS 2 rows. I need the above to display my answer as 1 row;
amount (ref1), amount (ref2).
The following does combine and give me what i want. However, if one of the queries does NOT return anything from the database then nothing is returned. I need it always to return something. (There will always be 1 query that will return something).
What i have so far which is not quite right;
SELECT * FROM(
SELECT amount
FROM Table a
WHERE REFERENCE = 1) A
(SELECT amount
FORM Table b
WHERE REFERENCE = 2)B
This does return what i need. However, if i amend the query for one of the select statements to say reference 3 which does not exist. Nothing is returned. I would still want reference 1 returned and null for the second query.
Requre outputs;
1, 1
1, null
null, 1
null, null will never occur.
Any help would be appreciated.
Thanks in advance
Comment