 




<?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: I want to select months from Jan to Dec using SQL query</title>
	<atom:link href="http://itknowledgeexchange.techtarget.com/itanswers/i-want-to-select-months-from-jan-to-dec-using-sql-query/feed/" rel="self" type="application/rss+xml" />
	<link>http://itknowledgeexchange.techtarget.com/itanswers/i-want-to-select-months-from-jan-to-dec-using-sql-query/</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: carlosdl</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/i-want-to-select-months-from-jan-to-dec-using-sql-query/#comment-89129</link>
		<dc:creator>carlosdl</dc:creator>
		<pubDate>Tue, 08 Mar 2011 22:19:53 +0000</pubDate>
		<guid isPermaLink="false">#comment-89129</guid>
		<description><![CDATA[Good job, Cyberloco ;-)]]></description>
		<content:encoded><![CDATA[<p>Good job, Cyberloco <img src='http://itknowledgeexchange.techtarget.com/itanswers/wp-includes/images/smilies/icon_wink.gif' alt=';-)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cyberloco</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/i-want-to-select-months-from-jan-to-dec-using-sql-query/#comment-89105</link>
		<dc:creator>cyberloco</dc:creator>
		<pubDate>Tue, 08 Mar 2011 14:08:37 +0000</pubDate>
		<guid isPermaLink="false">#comment-89105</guid>
		<description><![CDATA[I just realized that it has similatiry with  the one provided by  Mr. Msi777.]]></description>
		<content:encoded><![CDATA[<p>I just realized that it has similatiry with  the one provided by  Mr. Msi777.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: cyberloco</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/i-want-to-select-months-from-jan-to-dec-using-sql-query/#comment-89104</link>
		<dc:creator>cyberloco</dc:creator>
		<pubDate>Tue, 08 Mar 2011 14:06:21 +0000</pubDate>
		<guid isPermaLink="false">#comment-89104</guid>
		<description><![CDATA[Hi guys !! =D I think I can finally can collaborate in a good manner =D. Check out this one:

&lt;code&gt;SELECT TOP 12
DATENAME(MONTH, DATEADD(MONTH,ROW_NUMBER() OVER (ORDER BY object_id) - 1,0))
FROM sys.columns&lt;/code&gt;

Do you like it?]]></description>
		<content:encoded><![CDATA[<p>Hi guys !! =D I think I can finally can collaborate in a good manner =D. Check out this one:</p>
<p><code>SELECT TOP 12<br />
DATENAME(MONTH, DATEADD(MONTH,ROW_NUMBER() OVER (ORDER BY object_id) - 1,0))<br />
FROM sys.columns</code></p>
<p>Do you like it?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: msi77</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/i-want-to-select-months-from-jan-to-dec-using-sql-query/#comment-89053</link>
		<dc:creator>msi77</dc:creator>
		<pubDate>Mon, 07 Mar 2011 19:58:52 +0000</pubDate>
		<guid isPermaLink="false">#comment-89053</guid>
		<description><![CDATA[&gt; without using pl/sql 

t-sql

&gt;and less union

one union
^-))
&lt;pre&gt;with mth as(
select 1 as mnum
union all 
select 1 + mnum from mth where mnum&lt;12)
select mnum, datename(month,DATEADD(month,mnum-1,&#039;010101&#039;))  from mth;&lt;/pre&gt;]]></description>
		<content:encoded><![CDATA[<p>&gt; without using pl/sql </p>
<p>t-sql</p>
<p>&gt;and less union</p>
<p>one union<br />
^-))</p>
<pre>with mth as(
select 1 as mnum
union all 
select 1 + mnum from mth where mnum&lt;12)
select mnum, datename(month,DATEADD(month,mnum-1,'010101'))  from mth;</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: mehra</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/i-want-to-select-months-from-jan-to-dec-using-sql-query/#comment-89006</link>
		<dc:creator>mehra</dc:creator>
		<pubDate>Sat, 05 Mar 2011 06:22:03 +0000</pubDate>
		<guid isPermaLink="false">#comment-89006</guid>
		<description><![CDATA[From database table  you access  months in Data Table  object 
by using  query  &lt;pre&gt;
&quot; SELECT * FROM  tableMonth&quot;&lt;b&gt;

then catch in DataTable object of  ADO.net

&lt;code&gt;&lt;/pre&gt;
public DataTable SelectPeron(int Pid)
        {
            &lt;code&gt;DataTable tab = new DataTable();
            string Con = @&quot;Data Source=sureit44;Initial Catalog=MydataBase;Persist Security Info=True;User ID=sitdev;Password=sitdev1&quot;;
            using (SqlConnection con = new SqlConnection(Con))
            {
                string query=&quot;Select  * FROM  tableMonth&quot;;
                SqlCommand cmd = new SqlCommand(query, con);
                con.Open();
               
                using (SqlDataAdapter da = new SqlDataAdapter(cmd))
                da.Fill(tab);
                con.Close();&lt;/code&gt;
            }
            return tab;&lt;/code&gt;

&lt;/b&gt;After that Bind the tab object With DropDownList 
&lt;pre&gt;
ddl.DataSource=tab;
ddl.DataBind();

I think this will help you  and  u will get  your  d -zire result
Thanks&lt;/pre&gt;]]></description>
		<content:encoded><![CDATA[<p>From database table  you access  months in Data Table  object<br />
by using  query
<pre>
" SELECT * FROM  tableMonth"<b>

then catch in DataTable object of  ADO.net

<code></code></b></pre>
<p>public DataTable SelectPeron(int Pid)<br />
        {<br />
            <code>DataTable tab = new DataTable();<br />
            string Con = @"Data Source=sureit44;Initial Catalog=MydataBase;Persist Security Info=True;User ID=sitdev;Password=sitdev1";<br />
            using (SqlConnection con = new SqlConnection(Con))<br />
            {<br />
                string query="Select  * FROM  tableMonth";<br />
                SqlCommand cmd = new SqlCommand(query, con);<br />
                con.Open();</p>
<p>                using (SqlDataAdapter da = new SqlDataAdapter(cmd))<br />
                da.Fill(tab);<br />
                con.Close();</code><br />
            }<br />
            return tab;</p>
<p>After that Bind the tab object With DropDownList </p>
<pre>
ddl.DataSource=tab;
ddl.DataBind();

I think this will help you  and  u will get  your  d -zire result
Thanks</pre>
]]></content:encoded>
	</item>
	<item>
		<title>By: kccrosser</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/i-want-to-select-months-from-jan-to-dec-using-sql-query/#comment-63226</link>
		<dc:creator>kccrosser</dc:creator>
		<pubDate>Wed, 06 May 2009 20:46:30 +0000</pubDate>
		<guid isPermaLink="false">#comment-63226</guid>
		<description><![CDATA[Bizarre - why no union, which would make that trivial?

With those constraints, I think you are correct that the only solution is a table of month names.]]></description>
		<content:encoded><![CDATA[<p>Bizarre &#8211; why no union, which would make that trivial?</p>
<p>With those constraints, I think you are correct that the only solution is a table of month names.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: carlosdl</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/i-want-to-select-months-from-jan-to-dec-using-sql-query/#comment-63164</link>
		<dc:creator>carlosdl</dc:creator>
		<pubDate>Tue, 05 May 2009 18:33:21 +0000</pubDate>
		<guid isPermaLink="false">#comment-63164</guid>
		<description><![CDATA[I guess he wants to select the month names to populate a list box.

january
february
march
...]]></description>
		<content:encoded><![CDATA[<p>I guess he wants to select the month names to populate a list box.</p>
<p>january<br />
february<br />
march<br />
&#8230;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: kccrosser</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/i-want-to-select-months-from-jan-to-dec-using-sql-query/#comment-63153</link>
		<dc:creator>kccrosser</dc:creator>
		<pubDate>Tue, 05 May 2009 16:59:32 +0000</pubDate>
		<guid isPermaLink="false">#comment-63153</guid>
		<description><![CDATA[Some additional information on your data structure and requirements would help.

Assuming your data is in a table with a date and a value, e.g.:

&lt;code&gt;table myTable (
theDate  date,
theValue   integer);&lt;/code&gt;

and you want to generate a result set with the sum of the values that fall within the given months, you could use:

&lt;code&gt;select
jandata.total &quot;Jan&quot;, febdata.total &quot;Feb&quot;, mardata.total &quot;Mar&quot;, aprdata.total &quot;Apr&quot;, ...
from
(select sum(theValue) total from myTable where theDate &gt;= &#039;01/01/2009&#039; and theDate &lt; &#039;02/01/2009&#039;) jandata,
(select sum(theValue) total from myTable where theDate &gt;= &#039;02/01/2009&#039; and theDate &lt; &#039;03/01/2009&#039;) febdata,
(select sum(theValue) total from myTable where theDate &gt;= &#039;03/01/2009&#039; and theDate &lt; &#039;04/01/2009&#039;) mardata,
...&lt;/code&gt;

This is brute force, but doesn&#039;t require any PL/SQL or unions.

(Above is in Transact-SQL, in Oracle you would need to cast the dates using the &quot;to_date&quot; function.)]]></description>
		<content:encoded><![CDATA[<p>Some additional information on your data structure and requirements would help.</p>
<p>Assuming your data is in a table with a date and a value, e.g.:</p>
<p><code>table myTable (<br />
theDate  date,<br />
theValue   integer);</code></p>
<p>and you want to generate a result set with the sum of the values that fall within the given months, you could use:</p>
<p><code>select<br />
jandata.total "Jan", febdata.total "Feb", mardata.total "Mar", aprdata.total "Apr", ...<br />
from<br />
(select sum(theValue) total from myTable where theDate &gt;= '01/01/2009' and theDate &lt; '02/01/2009') jandata,<br />
(select sum(theValue) total from myTable where theDate &gt;= '02/01/2009' and theDate &lt; '03/01/2009') febdata,<br />
(select sum(theValue) total from myTable where theDate &gt;= '03/01/2009' and theDate &lt; '04/01/2009') mardata,<br />
...</code></p>
<p>This is brute force, but doesn&#8217;t require any PL/SQL or unions.</p>
<p>(Above is in Transact-SQL, in Oracle you would need to cast the dates using the &#8220;to_date&#8221; function.)</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.045 seconds using memcached
Object Caching 369/375 objects using memcached

Served from: itknowledgeexchange.techtarget.com @ 2013-05-19 15:48:12 -->