 




<?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: Select single row</title>
	<atom:link href="http://itknowledgeexchange.techtarget.com/itanswers/select-single-row/feed/" rel="self" type="application/rss+xml" />
	<link>http://itknowledgeexchange.techtarget.com/itanswers/select-single-row/</link>
	<description></description>
	<lastBuildDate>Sun, 19 May 2013 03:14:28 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
	<item>
		<title>By: gullu1</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/select-single-row/#comment-46093</link>
		<dc:creator>gullu1</dc:creator>
		<pubDate>Tue, 20 Jun 2006 13:15:12 +0000</pubDate>
		<guid isPermaLink="false">#comment-46093</guid>
		<description><![CDATA[Hi everyone,

Thanks for all these replies. Actually my problem was a tricky one . I figured that out. May be I did not give more clarification. The problem was , I got an user request to get data from 2 tables then create another table out of it, then he can show it in the web site. 
He wants columns like productNo, description,  division,transit, some other columns.., then for the quantity and date columns he wants to select by the location. location is one of the columns in the one of the 2 tables. He wants if the location is 01 then the quantity
will for that location will be put in a new column like qty_01, same  for the date like date_01. The table has 6 different locations. And productNO. can have multiple locations. So when I did case like
Case table2.location when 01 then -- else 0. It did not work. It will put multiple rows for the ProductNo column which he doesn&#039;t want. So I created 3 stored procedures. One will insert into the distinct productNo, and all other columns into the new table except the qty_01,date_01 columns.Then I declare a cursor and fetch the productNo and passing that productNo I call another procedure which will get the location for that productNo then passing both productNo and location i call the third procedure which will update the qty_xx, and date_xx columns and put the values in there. This one works fine. Thanks..]]></description>
		<content:encoded><![CDATA[<p>Hi everyone,</p>
<p>Thanks for all these replies. Actually my problem was a tricky one . I figured that out. May be I did not give more clarification. The problem was , I got an user request to get data from 2 tables then create another table out of it, then he can show it in the web site.<br />
He wants columns like productNo, description,  division,transit, some other columns.., then for the quantity and date columns he wants to select by the location. location is one of the columns in the one of the 2 tables. He wants if the location is 01 then the quantity<br />
will for that location will be put in a new column like qty_01, same  for the date like date_01. The table has 6 different locations. And productNO. can have multiple locations. So when I did case like<br />
Case table2.location when 01 then &#8212; else 0. It did not work. It will put multiple rows for the ProductNo column which he doesn&#8217;t want. So I created 3 stored procedures. One will insert into the distinct productNo, and all other columns into the new table except the qty_01,date_01 columns.Then I declare a cursor and fetch the productNo and passing that productNo I call another procedure which will get the location for that productNo then passing both productNo and location i call the third procedure which will update the qty_xx, and date_xx columns and put the values in there. This one works fine. Thanks..</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: invisflare</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/select-single-row/#comment-46094</link>
		<dc:creator>invisflare</dc:creator>
		<pubDate>Mon, 19 Jun 2006 09:08:13 +0000</pubDate>
		<guid isPermaLink="false">#comment-46094</guid>
		<description><![CDATA[Really need some clarification from the gullu1...  A table has multiple quantity@location columns and a table has only location-quantity column pair will have very different solutions.  

Also in a multiple quantity@location scenario, the design (or data load procedure) is probably flawed to allow multiple rows with the same product number, which should be the primary key.]]></description>
		<content:encoded><![CDATA[<p>Really need some clarification from the gullu1&#8230;  A table has multiple quantity@location columns and a table has only location-quantity column pair will have very different solutions.  </p>
<p>Also in a multiple quantity@location scenario, the design (or data load procedure) is probably flawed to allow multiple rows with the same product number, which should be the primary key.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: moosedrool</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/select-single-row/#comment-46095</link>
		<dc:creator>moosedrool</dc:creator>
		<pubDate>Mon, 19 Jun 2006 08:57:37 +0000</pubDate>
		<guid isPermaLink="false">#comment-46095</guid>
		<description><![CDATA[If you are using MSSQL then I would do it this way:

select ProcuctNo,Description,Sum(isnull(loc_qty_x)) as &#039;loc_qty_x&#039;, 
Sum(isnull(loc_qty_y)) as &#039;loc_qty_y&#039;,Sum(isnull(loc_qty_z)) as &#039;loc_qty_z&#039;
group by ProductNo,Description where productNo = &#039;blah&#039;]]></description>
		<content:encoded><![CDATA[<p>If you are using MSSQL then I would do it this way:</p>
<p>select ProcuctNo,Description,Sum(isnull(loc_qty_x)) as &#8216;loc_qty_x&#8217;,<br />
Sum(isnull(loc_qty_y)) as &#8216;loc_qty_y&#8217;,Sum(isnull(loc_qty_z)) as &#8216;loc_qty_z&#8217;<br />
group by ProductNo,Description where productNo = &#8216;blah&#8217;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: gematrian</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/select-single-row/#comment-46096</link>
		<dc:creator>gematrian</dc:creator>
		<pubDate>Sun, 18 Jun 2006 21:14:44 +0000</pubDate>
		<guid isPermaLink="false">#comment-46096</guid>
		<description><![CDATA[Seems like you already have the multple quantity columns.  Just use a SUM() on each of the Quantity columns, and do a GROUP BY on the product code and description columns.  SUM will ignore all the null values so that shouldn&#039;t be an issue.]]></description>
		<content:encoded><![CDATA[<p>Seems like you already have the multple quantity columns.  Just use a SUM() on each of the Quantity columns, and do a GROUP BY on the product code and description columns.  SUM will ignore all the null values so that shouldn&#8217;t be an issue.</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/10 queries in 0.053 seconds using memcached
Object Caching 309/315 objects using memcached

Served from: itknowledgeexchange.techtarget.com @ 2013-05-19 15:11:33 -->