February 21st, 2013, 04:13 PM
Case subquery displays
I need to display the customer or business name as "Customer" & combine the following into 1 query:
SELECT a.account_id, a.cust_id, a.last_activity_date, a.open_emp_id,
CONCAT(e.fname, ' ', e.lname) AS opened_by, a.avail_balance
FROM account a INNER JOIN employee e
ON a.open_emp_id = e. emp_id
WHERE NOT EXISTS (SELECT 1
FROM transaction t
WHERE t.txn_date = a.last_activity_date);
SELECT c.cust_id, c.cust_type_cd,
WHEN c.cust_type_cd = 'I'
THEN CONCAT(i.fname, ' ', i.lname)
WHEN c.cust_type_cd = 'B'
FROM customer c LEFT OUTER JOIN individual i
ON c.cust_id = i.cust_id
LEFT OUTER JOIN business b
ON c.cust_id = b.cust_id;
February 21st, 2013, 05:22 PM
how did you want them combined? in a UNION?
or are account employees somehow related to customer individual businesses?