63 lines
3.8 KiB
HTML
63 lines
3.8 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="Example: Comparisons involving UDTs" />
|
||
|
<meta name="abstract" content="Suppose you want to know which products sold more in the U.S. than in Canada and Germany for the month of March, 2003 (3/03)." />
|
||
|
<meta name="description" content="Suppose you want to know which products sold more in the U.S. than in Canada and Germany for the month of March, 2003 (3/03)." />
|
||
|
<meta name="DC.subject" content="UDTs (User-defined types), comparisons involving UDTs example, examples, comparisons involving UDTs" />
|
||
|
<meta name="keywords" content="UDTs (User-defined types), comparisons involving UDTs example, examples, comparisons involving UDTs" />
|
||
|
<meta name="DC.Relation" scheme="URI" content="rbafyexampudt.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="rbafyudtcomp" />
|
||
|
<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>Example: Comparisons involving UDTs</title>
|
||
|
</head>
|
||
|
<body id="rbafyudtcomp"><a name="rbafyudtcomp"><!-- --></a>
|
||
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
||
|
<h1 class="topictitle1">Example: Comparisons involving UDTs</h1>
|
||
|
<div><p>Suppose you want to know which products sold more in the U.S. than
|
||
|
in Canada and Germany for the month of March, 2003 (3/03).</p>
|
||
|
<div class="section"><p>Issue the following SELECT statement: </p>
|
||
|
<pre> <strong>SELECT</strong> US.PRODUCT_ITEM, US.TOTAL
|
||
|
<strong>FROM</strong> US_SALES <strong>AS</strong> US, CANADIAN_SALES <strong>AS</strong> CDN, GERMAN_SALES <strong>AS</strong> GERMAN
|
||
|
<strong>WHERE</strong> US.PRODUCT_ITEM = CDN.PRODUCT_ITEM
|
||
|
<strong>AND</strong> US.PRODUCT_ITEM = GERMAN.PRODUCT_ITEM
|
||
|
<strong>AND</strong> US.TOTAL > US_DOLLAR (CDN.TOTAL)
|
||
|
<strong>AND</strong> US.TOTAL > US_DOLLAR (GERMAN.TOTAL)
|
||
|
<strong>AND</strong> US.MONTH = 3
|
||
|
<strong>AND</strong> US.YEAR = 2003
|
||
|
<strong>AND</strong> CDN.MONTH = 3
|
||
|
<strong>AND</strong> CDN.YEAR = 2003
|
||
|
<strong>AND</strong> GERMAN.MONTH = 3
|
||
|
<strong>AND</strong> GERMAN.YEAR = 2003</pre>
|
||
|
</div>
|
||
|
<div class="section"><p>Because you cannot directly compare U.S. dollars
|
||
|
with Canadian dollars or Euros, you use the UDF to cast the amount in Canadian
|
||
|
dollars to U.S. dollars, and the UDF to cast the amount in Euros to U.S.
|
||
|
dollars. You cannot cast them all to DECIMAL and compare the converted DECIMAL
|
||
|
values because the amounts are not monetarily comparable as they are not in
|
||
|
the same currency. </p>
|
||
|
</div>
|
||
|
</div>
|
||
|
<div>
|
||
|
<div class="familylinks">
|
||
|
<div class="parentlink"><strong>Parent topic:</strong> <a href="rbafyexampudt.htm" title="These are examples of using UDTs.">Examples: Use UDTs</a></div>
|
||
|
</div>
|
||
|
</div>
|
||
|
</body>
|
||
|
</html>
|