Archives of the TeradataForum
Message Posted: Tue, 06 Nov 2007 @ 21:21:19 GMT
I have a column with a number of hours for different offices. What I am trying to achieve is to calculate the percentage of hours for each office and display the following:
OFFICE | HOURS | PERCENT_OF_TOTAL_HRS |
Below is the SQL query that I thought would work.
SELECT A1.OFFICE, SUM(A1.HOURS) AS HOURS, (SUM(A1.HOURS) / (SELECT SUM(A2.HOURS) FROM TABLE AS A2)) AS HRSPCT FROM TABLE AS A1 WHERE A1.OFFICE LIKE 'AD%' GROUP BY A1.OFFICE;
When I execute this query it tells me that I am missing something by the '(' and the 'SELECT' statement. I am fairly new to Teradata and SQL so any response is greatly appreciated.
|Copyright 2016 - All Rights Reserved|
|Last Modified: 27 Dec 2016|