I would like to combine two tables. The first table (tbl1) contains all Articles I need. The second table (tbl2) contains some additional information - but not for every article. That means in tbl2 are some columns where there is no value. I am using the following join:
SELECT *
FROM tbl1
LEFT JOIN tbl2 ON tbl1.c4 = tbl2.C4
this join filters all articles, where tbl2.c4 = ''. But I need the total articles that are listed in tbl1.
How can I manage that?
It is based on Oracle
You can use window functions. I think:
SELECT *
FROM (SELECT t1.*, COUNT(*) OVER () as cnt
FROM tbl1
) t1 LEFT JOIN
tbl2
ON t1.c4 = tbl2.C4;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.