I have 2 queries
Q1:
SELECT tc_ghy07,tc_ghy12
FROM tc_ghy_file
WHERE tc_ghy02 = 'DNF-000414'
AND tc_ghy01=TO_CHAR(YEAR(CURRENT_DATE))
Result:
+----------+----------+
| TC_GHY07 | TC_GHY12 |
+----------+----------+
| 16 | 0 |
+----------+----------+
Q2:
SELECT ( SUM(DECODE(tc_soa38,NULL,0,tc_soa38)+ decode(tc_soa39,NULL,0,tc_soa39*1.5)
+ DECODE(tc_soa40,NULL,0,tc_soa40 * 1.6) + decode(tc_soa41,NULL, 0,tc_soa41 * 2) +
decode(tc_soa42,NULL,0,tc_soa42
* 2.1) + DECODE(tc_soa43, NULL, 0,tc_soa43 * 2.7)
+ DECODE(tc_soa44,NULL, 0,tc_soa44 * 3) + DECODE(tc_soa45, NULL,0,tc_soa45 *
3.9)) ) / 8 AS result
FROM tc_soa_file
WHERE tc_soa33 = 'BU'
AND tc_soa04 = 'DNF-000414'
AND year(tc_soa07) = year(current_date);
Result:
+--------+
| RESULT |
+--------+
| 20 |
+--------+
How can I join 2 these tables into one query?
I have tried Union All or Cross join but it's not right. Thanks for helping
I want to query 2 these query in one query and the result will like this
+-----------+----------+--------+
| TC_GHY07 | TC_GHY12 | RESULT |
+-----------+----------+--------+
| 16 | 0 | 20 |
+-----------+----------+--------+
Edit: Join condition is tc_ghy02=tc_soa04
YEAR(CURRENT_DATE)is invalid for Oracle - are you sure you are using that?select year(CURRENT_DATE) from dualand result is 2019, it's ok, but how aboutselect year(SYSDATE) from dualDECODE(tc_soa39,NULL,0,tc_soa39*1.5)toNVL(1.5 * tc_soa39, 0)orCOALESCE(1.5 * tc_soa39, 0)and so on.select year(CURRENT_DATE) from dualworks for you, then you are not using Oracle: dbfiddle.uk/…