Introduction to PowerBuilder

HomePrevious Lesson: Group By Clause
Next Lesson: Compute Clause

Having Clause

It is used to specify criteria for a group and is created similar to the WHERE clause. As an illustration we could further refine the above example to list all the transaction dates and total quantity where the total receipts of Unit measurement type products for that day exceeding 10000.
SELECT "trans"."tran_date",
       sum("trans"."tran_qty")
   FROM "trans",
        "product_master"
   WHERE "product_master"."product_no" = 
         "trans"."tran_item_no" AND
         "trans"."tran_type" = 'R' AND
         "product_master"."product_measuring_unit" = 'U'
	GROUP BY "trans"."tran_date"
   HAVING ( sum("trans"."tran_qty") > 10000 )

You can see that the structure is exactly the same as the WHERE clause. Our DataWindow is quite simple so we don't need to specify any extra criteria. This clause is seldom used with Adaptive Server Anywhere database because of its poor support for the GROUP BY clause (Actually that's not poor support. They are sticking to the ANSI standards where as Sybase Adaptive Server Enterprise enhances the ANSI SQL and allow you to do so).
HomePrevious Lesson: Group By Clause
Next Lesson: Compute Clause