- Home
- Products
- Integration
- Tutorial
- Barcode FAQ
- Purchase
- Company
create barcode using vb.net RETRIEVAL: MULTIPLE TABLES AND AGGREGATION in Java
RETRIEVAL: MULTIPLE TABLES AND AGGREGATION Creating Data Matrix In Java Using Barcode maker for Android Control to generate, create ECC200 image in Android applications. www.OnBarcode.comEAN13 Creation In Java Using Barcode encoder for Android Control to generate, create EAN13 image in Android applications. www.OnBarcode.comIn summary, if your query contains a GROUP BY clause, the SELECT clause is allowed to contain only group expressions. A group expression is a column name that is part of the GROUP BY clause, or a group function applied to any other column expression. See also Table 8-3 at the end of Section 8.6. Code 128 Code Set C Printer In Java Using Barcode creator for Android Control to generate, create Code 128 Code Set A image in Android applications. www.OnBarcode.comCreate PDF-417 2d Barcode In Java Using Barcode creation for Android Control to generate, create PDF-417 2d barcode image in Android applications. www.OnBarcode.com8.8 Advanced GROUP BY Features
Barcode Maker In Java Using Barcode generation for Android Control to generate, create Barcode image in Android applications. www.OnBarcode.comDrawing USS Code 39 In Java Using Barcode encoder for Android Control to generate, create ANSI/AIM Code 39 image in Android applications. www.OnBarcode.comThe previous sections showed examples of using standard GROUP BY clauses. You can also use some more advanced features of the GROUP BY clause. Here, we will look at GROUP BY CUBE and GROUP BY ROLLUP. Let s start with a regular GROUP BY example, shown in Listing 8-36. Listing 8-36. Regular GROUP BY Example select , from group by DEPTNO -------10 10 10 20 20 30 30 30 deptno, job count(empno) headcount employees deptno, job; JOB HEADCOUNT ---------- --------MANAGER 1 DIRECTOR 1 ADMIN 1 MANAGER 1 TRAINER 4 MANAGER 1 SALESREP 4 ADMIN 1 Make GS1-128 In Java Using Barcode creator for Android Control to generate, create GS1 128 image in Android applications. www.OnBarcode.comOneCode Printer In Java Using Barcode generation for Android Control to generate, create OneCode image in Android applications. www.OnBarcode.comYou get an overview with the number of employees per department, and within each department per job. To keep things simple, let s forget about department 40, the department without employees. Generating ECC200 In None Using Barcode encoder for Software Control to generate, create Data Matrix ECC200 image in Software applications. www.OnBarcode.comDataMatrix Maker In Objective-C Using Barcode creator for iPhone Control to generate, create Data Matrix ECC200 image in iPhone applications. www.OnBarcode.comGROUP BY ROLLUP
UPC A Drawer In None Using Barcode generator for Online Control to generate, create UPC Symbol image in Online applications. www.OnBarcode.comPrinting Code-39 In .NET Framework Using Barcode printer for Reporting Service Control to generate, create ANSI/AIM Code 39 image in Reporting Service applications. www.OnBarcode.comNotice what happens if you change the GROUP BY clause and add the keyword ROLLUP, as shown in Listing 8-37. Listing 8-37. GROUP BY ROLLUP Example select , from group by DEPTNO -------10 10 deptno, job count(empno) headcount employees ROLLUP(deptno, job); JOB HEADCOUNT -------- --------ADMIN 1 MANAGER 1 Reading Barcode In VB.NET Using Barcode Control SDK for Visual Studio .NET Control to generate, create, read, scan barcode image in Visual Studio .NET applications. www.OnBarcode.comBarcode Generation In None Using Barcode printer for Font Control to generate, create Barcode image in Font applications. www.OnBarcode.comRETRIEVAL: MULTIPLE TABLES AND AGGREGATION
Quick Response Code Decoder In Java Using Barcode decoder for Java Control to read, scan read, scan image in Java applications. www.OnBarcode.comRecognizing PDF417 In Java Using Barcode scanner for Java Control to read, scan read, scan image in Java applications. www.OnBarcode.com>>> >>>
Encode UCC - 12 In None Using Barcode creation for Online Control to generate, create EAN / UCC - 13 image in Online applications. www.OnBarcode.comCreate Code 39 Full ASCII In None Using Barcode generator for Software Control to generate, create Code 39 Full ASCII image in Software applications. www.OnBarcode.com>>> >>>
EAN 13 Decoder In Java Using Barcode scanner for Java Control to read, scan read, scan image in Java applications. www.OnBarcode.comEncode Code128 In .NET Using Barcode creator for ASP.NET Control to generate, create USS Code 128 image in ASP.NET applications. www.OnBarcode.com10 10 20 20 20 30 30 30 30 DIRECTOR MANAGER TRAINER ADMIN MANAGER SALESREP
1 3 1 4 5 1 1 4 6 14 <<< <<<
<<< <<<
The ROLLUP addition results in four additional rows, marked with >>> and <<< in Listing 8-37 for readability. Three of these four additional rows show the head count per department over all jobs, and the last row shows the total number of employees. GROUP BY CUBE
You can also use the CUBE keyword in the GROUP BY clause. Listing 8-38 shows an example. Listing 8-38. GROUP BY CUBE Example select , from group by deptno, job count(empno) headcount employees CUBE(deptno, job); DEPTNO JOB HEADCOUNT -------- -------- --------14 >>> ADMIN 2 >>> MANAGER 3 >>> TRAINER 4 >>> DIRECTOR 1 >>> SALESREP 4 10 3 10 MANAGER 1 10 DIRECTOR 1 10 ADMIN 1 20 5 20 MANAGER 1 20 TRAINER 4 30 6 30 MANAGER 1 30 SALESREP 4 30 ADMIN 1 <<< <<< <<< <<< <<<
This time, you get five more rows in the query result, marked in the same way with >>> and <<<, showing the number of employees per job, regardless of which department employs them. RETRIEVAL: MULTIPLE TABLES AND AGGREGATION
Tip Both GROUP BY CUBE and GROUP BY ROLLUP are special cases of the GROUP BY GROUPING SETS syntax, offering more flexibility. You can also merge the results of different grouping operations into a single GROUP BY clause by specifying them in a comma-separated list. For more details, see Oracle SQL Reference. CUBE, ROLLUP, and Null Values
The CUBE and ROLLUP keywords generate many null values in query results, as you can see in Listings 8-37 and 8-38. You can distinguish these system-generated null values from other null values; for example, to replace them with some explanatory text. You can use the GROUPING and GROUPING_ID functions for that purpose. The GROUPING Function
Listing 8-39 shows an example \of the GROUPING function. Listing 8-39. GROUPING Function Example select , deptno case GROUPING(job) when 0 then job when 1 then '**total**' end job , count(empno) headcount from employees group by rollup(deptno, job); DEPTNO -------10 10 10 10 20 20 20 30 30 30 30 JOB HEADCOUNT --------- --------ADMIN 1 MANAGER 1 DIRECTOR 1 **total** 3 MANAGER 1 TRAINER 4 **total** 5 ADMIN 1 MANAGER 1 SALESREP 4 **total** 6 **total** 14 Unfortunately, the GROUPING function can return only two results: 0 or 1. That s why the last two lines both show '**total**'.
|
|