0

What is the equivalent query for

SELECT *,SUM(total_request_count) AS total_calls FROM API_REQUEST_SUMMARY 

in DB2. It says * is invalid in db2 data explorer. After running this I got below error

An unexpected token "*" was found following "SELECT ". Expected tokens may include: "NULL".. SQLCODE=-104, SQLSTATE=42601, DRIVER=3.68.61 

Any Idea to resolve this is much appreciated.

1 Answer 1

1

any not aggregated column must be included in GROUP BY

SELECT COL1, COL2 ,SUM(total_request_count) AS total_calls FROM API_REQUEST_SUMMARY GROUP BY COL1, COL2 

alternative if many columns for GROUP BY

SELECT T1.*, T2.total_calls FROM API_REQUEST_SUMMARY T1 LEFT JOIN (SELECT GROUP_COLUMN, SUM(total_request_count) AS total_calls FROM API_REQUEST_SUMMARY GROUP BY GROUP_COLUMN) T2 ON T1.GROUP_COLUMN = T2.GROUP_COLUMN 

it is my work solution, may be other present as well

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.