Hello,
I'm using Oracle. I'm trying to compose something like this:
SELECT trans_type,
(SELECT parameter_value FROM transaction_details WHERE id = MAX(t.trans_id))
FROM
(SELECT trans_id, trans_type FROM transactions) t
GROUP BY trans_type
So, I am trying to use a result of grouping inside an inner query. But I am getting the error that I cannot use a group function inside the inner query:
ORA-00934: group function is not allowed here
Can you offer an alternative other than resorting to another outer query?
UPDATE
As requested, I am posting a shorter version of the real query:
SELECT service_code,
currency,
(SELECT value FROM exchange_rate WHERE date_added = MIN(t.trans_date)) AS exchange_rate,
TRIM(TO_CHAR(SUM(amount), '9999999990.99')) AS amount,
TRIM(TO_CHAR(SUM(tax_amount), '9999999990.99')) AS tax_amount,
TRIM(TO_CHAR(SUM(total_amount), '9999999990.99')) AS total_amount
FROM (SELECT t.amount AS amount,
t.trans_date AS trans_date
t.tax_amount AS tax_amount,
t.total_amount AS total_amount,
td1.string_value AS service_code,
td2.string_value AS currency
FROM transac) t
GROUP BY service_code, currency