Results 1 to 1 of 1
  1. #1
    Join Date
    May 2010
    Posts
    1

    Unanswered: Advanced exercise - FUNCTIONS AGGREGATES

    Hi. I am a beginner in the domain of databases. I learn a Postgresql encountered the practice in the field of aggregate functions, with which I do not know how to solve. Namely, I have a simplified structure of a table:
    Code:
    CREATE TABLE orders
    (
       orderid          INT               PRIMARY KEY,
       orderdate      Date,  
       totalamount   Numeric(12,2)
    )
    The database is a simple database to store CDs.
    Exercise is: the receipt of the quarter (season), the total value of orders placed by customers in 2004 was the lowest. Only I could write just the same thing:
    Code:
    SELECT EXTRACT(QUARTER FROM orderdate) AS "Quarter" FROM orders o
      WHERE EXTRACT(YEAR FROM orderdate)=2004 
        GROUP BY EXTRACT(QUARTER FROM orderdate)
    	HAVING SUM(totalamount) < ...
    and I do not know how to finish the query.
    Please help with writing a how to complete the choice of the quarter (season), the total value of orders placed by customers was the lowest.
    Thanks for help.
    Last edited by takedowner86; 05-16-10 at 06:00.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •