MCQs Test!! VB Basic Test !! Essentials of VB !! Creating User Services !! function !! Anatomy !! GK March-2019 !! DATA TYPES IN JAVA !! Classes ,Constructor ,Methods,Inheritance !! Ecology-I !! Biology 2019 !! Gk april 2019 !! Biology (living world) !! Plant anatomy !! CELL STRUCTURES AND FUNCTION !! General biology !! Human physiology !! Data structure !! Ecology-II !! GK TEST !! Reproduction in plants !! Human reproduction !! The ABC of C !! Operating system set1 !! Operating system set2 !! Gk and current affairs !! Animal kingdom !! Number system !! Animal kingdom-II !! Gk TEST-III !! Number series !! Microorganisms !! Interview question in c !! Time and Work !! Percentage !! General history !! Average !! Cells !! Locomotion and Movement !! paging !! Bacteriology !! Page replacement policy !! Secondary memory and Disk scheduling !! Introduction of Nervous System and neurons !! Plant harmones !! Transport and Mineral Nutrition in Plants !! Neurotransmitters !! Modern Indian History !! Photosynthesis in Plants !! Modern Indian History-II !! Plant respiration !! Environment & Biodiversity !! Environment & Biodiversity - II !! Algae, Bryophytes, Pteridophytes !! Area !! Cricket !! Days of the Year (India and the World) !! Plant Pathology - I !! Indian Transport System !! Plant Pathology - II !! Aptitude !! Biology !! Botany !! C language !! Computer Science !! Core Java !! Gate !! GK !! Mysql !! Operating system !! Physics !! VB-Visual Basic !! Zoology

DATABASE & SQL/PLSQL

Using COMPUTE BY Clause
Previous Home Next

Used to generate summary rows using aggregate function in the query results. COMPUTE BY clause can be used to calculate summary values of the result set on a group of data.The main difference between GROUP BY and COMPUTE BY Clause is,

GROUP BY Clause is used to generate a group summary report and does not produce individual table rows in the result set whereas COMPUTE BY Clause generate the summary report with individual data rows from the table.

SELECT  column_name
FROM  table_name
ORDER BY  column_name
COMPUTE  aggregate_function (column_name)  BY  column_name 1...column_name n

 

Example:

SELECT  type, advance
FROM  titles
ORDER BY  type
COMPUTE AVG (advance)  BY  type

output

Some points regarding the use of the COMPUTE and COMPUTE BY

  1. The DISTINCT keyword cannot be used with the aggregate function
  2. All columns referred to in the COMPUTE clause must appear in the select column list
  3. The ORDER BY Clause must be used whenever the COMPUTE BY Clause is used
  4. The ORDER BY Clause can be eliminate only when the COMPUTE BY Clause is used
  5. The column listed in the COMPUTE BY Clause must match the columns used in the ORDER BY Clause
  6. More than one COMPUTE clause can be used in the SELECT statement to produce a result with subtotals and grand total
  7. The different aggregate function can be used on more than one column with the COMPUTE BY Clause
  8. More than one column or expression can be specified after the COMPUTE BY clause. The order of columns or expression used in the COMPUTE BY clause must match the order of columns or expression specified in the ORDER BY Clause.
Previous Home Next