Просто мне нужно получить общее количество комментариев. Так что мой запрос нужно выбрать и посчитать. Вот мой sql. У меня проблема с total_comments
SELECT customid,
dt,
customer_name,
e_mail,
phone,
TYPE,
message,
crm_status_id,
total_comments
FROM (SELECT f.ROWID AS customid,
f.dt AS d,
To_char(f.dt, 'YYYY-MM-DD HH24:MI:SS') AS dt,
f.first_name
|| ' '
|| f.middle_name
|| ' '
|| f.last_name AS customer_name,
f.e_mail,
f.phone,
Decode(f.feedback_type, 'CALLBACK', 'CALLBACK',
'FEEDBACK') AS TYPE,
f.feedback_message AS message,
f.crm_status_id AS crm_status_id,
(SELECT COUNT(*) FROM CRM_FEEDBACK_COMMENTS WHERE CRM_FEEDBACK_COMMENTS.FEEDBACK_ROW_ID = f.customid) as total_comments
FROM crm_feedback f
UNION ALL
SELECT g.ROWID AS customid,
create_date AS d,
To_char(create_date, 'YYYY-MM-DD HH24:MI:SS') AS dt,
c.customer_name1 AS customer_name,
p.email,
p.phone,
'MOBILSHOBE FEEDBACK' AS TYPE,
g.message_body AS message,
g.crm_status_id AS crm_status_id,
(SELECT COUNT(*) FROM CRM_FEEDBACK_COMMENTS WHERE FEEDBACK_COMMENTS.FEEDBACK_ROW_ID = g.customid) as total_comments
FROM feedback g
inner join sttm_customer@fcc_dblink c
ON c.customer_no = g.customer_no
inner join pg2_customer@fcc_dblink p
ON p.cif = g.customer_no)
Я получил эту ошибку: [Err] ORA-00904: "F". "CUSTOMID": неверный идентификатор