<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Using Query on 4 different files</title>
	<atom:link href="http://itknowledgeexchange.techtarget.com/itanswers/using-query-on-4-different-files/feed/" rel="self" type="application/rss+xml" />
	<link>http://itknowledgeexchange.techtarget.com/itanswers/using-query-on-4-different-files/</link>
	<description></description>
	<lastBuildDate>Thu, 20 Jun 2013 04:39:12 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
	<item>
		<title>By: splat</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/using-query-on-4-different-files/#comment-87674</link>
		<dc:creator>splat</dc:creator>
		<pubDate>Mon, 07 Feb 2011 18:00:12 +0000</pubDate>
		<guid isPermaLink="false">#comment-87674</guid>
		<description><![CDATA[Query/400 will handle multiple files but to get all of your customers on the report you will need as a primary file one containing all of your customers.   Is there a reason you can&#039;t use your customer master file as the primary?]]></description>
		<content:encoded><![CDATA[<p>Query/400 will handle multiple files but to get all of your customers on the report you will need as a primary file one containing all of your customers.   Is there a reason you can&#8217;t use your customer master file as the primary?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tomliotta</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/using-query-on-4-different-files/#comment-87467</link>
		<dc:creator>tomliotta</dc:creator>
		<pubDate>Thu, 03 Feb 2011 03:11:14 +0000</pubDate>
		<guid isPermaLink="false">#comment-87467</guid>
		<description><![CDATA[Typo error correction -- this line:&lt;pre&gt;
     SELECT CNAME, 0 as Q1, 0 as Q2, 0 as Q4, CDTA as Q3  FROM cdta4&lt;/pre&gt;
...should be:&lt;pre&gt;
     SELECT CNAME, 0 as Q1, 0 as Q2, 0 as Q3, CDTA as Q4  FROM cdta4&lt;/pre&gt;
Tom]]></description>
		<content:encoded><![CDATA[<p>Typo error correction &#8212; this line:
<pre>
     SELECT CNAME, 0 as Q1, 0 as Q2, 0 as Q4, CDTA as Q3  FROM cdta4</pre>
<p>&#8230;should be:
<pre>
     SELECT CNAME, 0 as Q1, 0 as Q2, 0 as Q3, CDTA as Q4  FROM cdta4</pre>
<p>Tom</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: mariodlg</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/using-query-on-4-different-files/#comment-87450</link>
		<dc:creator>mariodlg</dc:creator>
		<pubDate>Wed, 02 Feb 2011 21:38:59 +0000</pubDate>
		<guid isPermaLink="false">#comment-87450</guid>
		<description><![CDATA[Look for the uses of LEFT/RIGHT OUTER JOIN, that way you can list data that exist only in one file, so you could list all of your customers information regardless if any of them not appear in one of the files.

Hope it complements the other answers.]]></description>
		<content:encoded><![CDATA[<p>Look for the uses of LEFT/RIGHT OUTER JOIN, that way you can list data that exist only in one file, so you could list all of your customers information regardless if any of them not appear in one of the files.</p>
<p>Hope it complements the other answers.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: tomliotta</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/using-query-on-4-different-files/#comment-87403</link>
		<dc:creator>tomliotta</dc:creator>
		<pubDate>Wed, 02 Feb 2011 02:42:59 +0000</pubDate>
		<guid isPermaLink="false">#comment-87403</guid>
		<description><![CDATA[You don&#039;t say what query product you&#039;re using, but it seems reasonable to assume that you mean &#039;Query for iSeries&#039; (or Query/400).

I can&#039;t quite see a good way to do it with Query/400, though I wouldn&#039;t be too surprised if someone had an idea. For the most part, I can&#039;t think of a good reason to use JOIN for this in the first place. To me, this seems much more like a UNION that a JOIN.

Here&#039;s a simple SQL way to express the structure:&lt;pre&gt;
with qsum (qname, q1, q2, q3, q4) as (
     SELECT CNAME, CDTA as Q1 , 0 as Q2, 0 as Q3, 0 as Q4 FROM cdta1
       union
     SELECT CNAME, 0 as Q1, CDTA as Q2 , 0 as Q3, 0 as Q4 FROM cdta2
       union
     SELECT CNAME, 0 as Q1, 0 as Q2, CDTA as Q3 , 0 as Q4 FROM cdta3
       union
     SELECT CNAME, 0 as Q1, 0 as Q2, 0 as Q4, CDTA as Q3  FROM cdta4
    )
select qname, sum(q1), sum(q2), sum(q3), sum(q4)
  from qsum
  group by qname&lt;/pre&gt;
You have four tables -- CDTA1 through CDTA4. The CDTA1 table has a name and an amount for the first period. The other three tables have names and amounts for the remaining three periods. Since there is no guarantee that any name will be in all four periods, there is no JOIN that can link everything together unless maybe you set up a very ugly combination of EXCEPTION JOINs in all directions. (And I&#039;m not sure if that could be made to work.)

Come to think of it, I suppose, for Query/400, you might create a multi-format LF over all of the periods that provided default zero values for the other three periods. You might then use that as input to your query and summarize the values.

To me, it seems far easier not to use Query/400 at all and just do it directly with a Query Manager query instead. You should almost be able to plug your field names into the example above and run it. I can&#039;t think of any reason still to be using Query/400.

Tom]]></description>
		<content:encoded><![CDATA[<p>You don&#8217;t say what query product you&#8217;re using, but it seems reasonable to assume that you mean &#8216;Query for iSeries&#8217; (or Query/400).</p>
<p>I can&#8217;t quite see a good way to do it with Query/400, though I wouldn&#8217;t be too surprised if someone had an idea. For the most part, I can&#8217;t think of a good reason to use JOIN for this in the first place. To me, this seems much more like a UNION that a JOIN.</p>
<p>Here&#8217;s a simple SQL way to express the structure:
<pre>
with qsum (qname, q1, q2, q3, q4) as (
     SELECT CNAME, CDTA as Q1 , 0 as Q2, 0 as Q3, 0 as Q4 FROM cdta1
       union
     SELECT CNAME, 0 as Q1, CDTA as Q2 , 0 as Q3, 0 as Q4 FROM cdta2
       union
     SELECT CNAME, 0 as Q1, 0 as Q2, CDTA as Q3 , 0 as Q4 FROM cdta3
       union
     SELECT CNAME, 0 as Q1, 0 as Q2, 0 as Q4, CDTA as Q3  FROM cdta4
    )
select qname, sum(q1), sum(q2), sum(q3), sum(q4)
  from qsum
  group by qname</pre>
<p>You have four tables &#8212; CDTA1 through CDTA4. The CDTA1 table has a name and an amount for the first period. The other three tables have names and amounts for the remaining three periods. Since there is no guarantee that any name will be in all four periods, there is no JOIN that can link everything together unless maybe you set up a very ugly combination of EXCEPTION JOINs in all directions. (And I&#8217;m not sure if that could be made to work.)</p>
<p>Come to think of it, I suppose, for Query/400, you might create a multi-format LF over all of the periods that provided default zero values for the other three periods. You might then use that as input to your query and summarize the values.</p>
<p>To me, it seems far easier not to use Query/400 at all and just do it directly with a Query Manager query instead. You should almost be able to plug your field names into the example above and run it. I can&#8217;t think of any reason still to be using Query/400.</p>
<p>Tom</p>
]]></content:encoded>
	</item>
</channel>
</rss>

<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Page Caching using memcached
Database Caching 3/8 queries in 0.035 seconds using memcached
Object Caching 311/312 objects using memcached

Served from: itknowledgeexchange.techtarget.com @ 2013-06-20 04:58:09 -->