79 lines
4.6 KiB
HTML
79 lines
4.6 KiB
HTML
|
<?xml version="1.0" encoding="UTF-8"?>
|
||
|
<!DOCTYPE html
|
||
|
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||
|
<html lang="en-us" xml:lang="en-us">
|
||
|
<head>
|
||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||
|
<meta name="security" content="public" />
|
||
|
<meta name="Robots" content="index,follow" />
|
||
|
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
|
||
|
<meta name="DC.Type" content="reference" />
|
||
|
<meta name="DC.Title" content="Grouping and joins with DB2 Multisystem" />
|
||
|
<meta name="abstract" content="If the query contains a join, the partitioning key used to determine the type of grouping that can be implemented is based on any repartitioning of data that was required to implement the join." />
|
||
|
<meta name="description" content="If the query contains a join, the partitioning key used to determine the type of grouping that can be implemented is based on any repartitioning of data that was required to implement the join." />
|
||
|
<meta name="DC.subject" content="grouping, with joins, join, with grouping" />
|
||
|
<meta name="keywords" content="grouping, with joins, join, with grouping" />
|
||
|
<meta name="DC.Relation" scheme="URI" content="grouping.htm" />
|
||
|
<meta name="DC.Relation" scheme="URI" content="grouping.htm" />
|
||
|
<meta name="copyright" content="(C) Copyright IBM Corporation 1998, 2006" />
|
||
|
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 1998, 2006" />
|
||
|
<meta name="DC.Format" content="XHTML" />
|
||
|
<meta name="DC.Identifier" content="groupjoin" />
|
||
|
<meta name="DC.Language" content="en-us" />
|
||
|
<!-- All rights reserved. Licensed Materials Property of IBM -->
|
||
|
<!-- US Government Users Restricted Rights -->
|
||
|
<!-- Use, duplication or disclosure restricted by -->
|
||
|
<!-- GSA ADP Schedule Contract with IBM Corp. -->
|
||
|
<link rel="stylesheet" type="text/css" href="./ibmdita.css" />
|
||
|
<link rel="stylesheet" type="text/css" href="./ic.css" />
|
||
|
<title>Grouping and joins with DB2 Multisystem</title>
|
||
|
</head>
|
||
|
<body id="groupjoin"><a name="groupjoin"><!-- --></a>
|
||
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
||
|
<h1 class="topictitle1">Grouping and joins with DB2<sup>®</sup> Multisystem</h1>
|
||
|
<div><p>If the query contains a join, the partitioning key used to determine
|
||
|
the type of grouping that can be implemented is based on any repartitioning
|
||
|
of data that was required to implement the join.</p>
|
||
|
<div class="section"><p>In the following example, a repartitioned join is performed before
|
||
|
the grouping, which results in a new partitioning key of MGRNO. Because MGRNO
|
||
|
is now the partitioning key, grouping can be performed using one-step grouping.
|
||
|
</p>
|
||
|
<p>SQL statement:</p>
|
||
|
<pre> SELECT MGRNO, COUNT(*)
|
||
|
FROM DEPARTMENT, EMPLOYEE
|
||
|
WHERE MGRNO = EMPNO
|
||
|
GROUP BY MGRNO
|
||
|
</pre>
|
||
|
<p>OPNQRYF command:</p>
|
||
|
<pre> OPNQRYF FILE((DEPARTMENT) (EMPLOYEE)) FORMAT(GRPFMT2)
|
||
|
JFLD((MGRNO EMPNO *EQ))
|
||
|
GRPFLD(MGRNO)
|
||
|
MAPFLD((CNTMGR '%COUNT'))</pre>
|
||
|
<p>In the following
|
||
|
example, a repartitioned join is performed before the grouping,
|
||
|
which results in a new partitioning key of EMPNO. Because EMPNO is now the
|
||
|
partitioning key instead of WORKDEPT, grouping cannot be performed using one-step
|
||
|
grouping. </p>
|
||
|
<p>SQL statement:</p>
|
||
|
<pre> SELECT WORKDEPT, COUNT(*)
|
||
|
FROM DEPARTMENT, EMPLOYEE
|
||
|
WHERE MGRNO = EMPNO
|
||
|
GROUP BY WORKDEPT
|
||
|
</pre>
|
||
|
<p>OPNQRYF command:</p>
|
||
|
<pre> OPNQRYF FILE((DEPARTMENT) (EMPLOYEE)) FORMAT(GRPFMT3)
|
||
|
JFLD((MGRNO EMPNO *EQ))
|
||
|
GRPFLD(WORKDEPT)
|
||
|
MAPFLD((CNTDEPT '%COUNT'))</pre>
|
||
|
</div>
|
||
|
</div>
|
||
|
<div>
|
||
|
<div class="familylinks">
|
||
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="grouping.htm" title="The implementation method for grouping in queries that use distributed files is dependent on whether the partitioning key is included in the grouping criteria.">Implementation and optimization of grouping with DB2 Multisystem</a></div>
|
||
|
</div>
|
||
|
<div class="relconcepts"><strong>Related concepts</strong><br />
|
||
|
<div><a href="grouping.htm" title="The implementation method for grouping in queries that use distributed files is dependent on whether the partitioning key is included in the grouping criteria.">Implementation and optimization of grouping with DB2 Multisystem</a></div>
|
||
|
</div>
|
||
|
</div>
|
||
|
</body>
|
||
|
</html>
|