1 Replies - 924 Views - Last Post: 30 September 2016 - 07:48 PM

#1 louied91  Icon User is offline

  • D.I.C Head

Reputation: 7
  • View blog
  • Posts: 89
  • Joined: 05-June 15

Oracle SQL Command: Averaging one column

Posted 30 September 2016 - 07:27 PM

Create a view named CONDO_FEES. It consists of two columns: the first is the square footage, and the second is the average fee for all condos in the CONDO_UNIT table that have that square footage. Use AVERAGE_FEE as the column name for the average fee. Group and order the rows by square footage.

a. Write and execute the CREATE VIEW command to create the CONDO_FEES view.

This is the code I wrote:

CREATE VIEW CONDO_FEES AS
SELECT SQR_FT, AVG(CONDO_FEE) AS AVERAGE_FEE
FROM CONDO_UNIT
GROUP BY SQR_FT
ORDER BY SQR_FT;


This is the other that I tried:
CREATE VIEW CONDO_FEES (SQR_FT, AVERAGE_FEE) AS
SELECT SQR_FT, AVG(CONDO_FEE)
FROM CONDO_UNIT
GROUP BY SQR_FT
ORDER BY SQR_FT;


It is not averaging all of the condo's together. It's only averaging condo's with the same square footage. Example:

Sqr_ft    Average_fee
1100      300
550       150.5
300       100
550       150.5
500       130

This post has been edited by louied91: 30 September 2016 - 07:47 PM


Is This A Good Question/Topic? 0
  • +

Replies To: Oracle SQL Command: Averaging one column

#2 louied91  Icon User is offline

  • D.I.C Head

Reputation: 7
  • View blog
  • Posts: 89
  • Joined: 05-June 15

Re: Oracle SQL Command: Averaging one column

Posted 30 September 2016 - 07:48 PM

This can be deleted. I read the question wrong and it asked for the average to the tables that have the particular square footage, which is what I have.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1