 




<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>IT Answers &#187; GROUP BY statement</title>
	<atom:link href="http://itknowledgeexchange.techtarget.com/itanswers/tag/group-by-statement/feed/" rel="self" type="application/rss+xml" />
	<link>http://itknowledgeexchange.techtarget.com/itanswers</link>
	<description></description>
	<lastBuildDate>Sat, 18 May 2013 00:58:41 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	
		<item>
		<title>SQL Group by Query with aggregate function as well as detail information</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/sql-group-by-query-with-aggregate-function-as-well-as-detail-information/</link>
		<comments>http://itknowledgeexchange.techtarget.com/itanswers/sql-group-by-query-with-aggregate-function-as-well-as-detail-information/#comments</comments>
		<pubDate>Mon, 08 Oct 2012 11:13:19 +0000</pubDate>
		<dc:creator>idontknowthis</dc:creator>
				<category><![CDATA[Access]]></category>
		<category><![CDATA[GROUP BY statement]]></category>
		<category><![CDATA[MAX]]></category>
		<category><![CDATA[Query]]></category>

		<guid isPermaLink="false">http://itknowledgeexchange.techtarget.com/itanswers/sql-group-by-query-with-aggregate-function-as-well-as-detail-information/</guid>
		<description><![CDATA[New Answer by TomLiotta]]></description>
				<content:encoded><![CDATA[New Answer by TomLiotta]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/itanswers/sql-group-by-query-with-aggregate-function-as-well-as-detail-information/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Keep the &#8220;first&#8221; value using groupby &#8211; MYSQL</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/keep-the-first-value-using-groupby-mysql/</link>
		<comments>http://itknowledgeexchange.techtarget.com/itanswers/keep-the-first-value-using-groupby-mysql/#comments</comments>
		<pubDate>Thu, 14 Oct 2010 19:51:28 +0000</pubDate>
		<dc:creator>Iamjeannie</dc:creator>
				<category><![CDATA[GROUP BY statement]]></category>
		<category><![CDATA[MySQL]]></category>
		<category><![CDATA[MySQL Database]]></category>
		<category><![CDATA[MySQL functions]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[Input : col1 col2 a      1 b       1 c        2 d       2 I would like to : Create the new colX to get the first value in col1 group by col2 and save the value in colX   results : col1 col2   colX a      1       a b       1      a c        2      c d       2       c [...]]]></description>
				<content:encoded><![CDATA[<p>Input : <br/><br/> col1 col2 <br/><br/> a      1<br/><br/> b       1<br/><br/> c        2<br/><br/> d       2<br/><br/> I would like to : <br/><br/> Create the new colX to get the first value in col1 group by col2 and save the value in colX<br/><br/>  <br/><br/> results : <br/><br/> col1 col2   colX<br/><br/> a      1       a<br/><br/> b       1      a<br/><br/> c        2      c<br/><br/> d       2       c<br/><br/>  <br/><br/> how can do it in mysql<br/><br/></p>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/itanswers/keep-the-first-value-using-groupby-mysql/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Query performance and tuning</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/performance-tuning/</link>
		<comments>http://itknowledgeexchange.techtarget.com/itanswers/performance-tuning/#comments</comments>
		<pubDate>Sun, 21 Dec 2008 09:34:55 +0000</pubDate>
		<dc:creator>Mingley</dc:creator>
				<category><![CDATA[GROUP BY statement]]></category>
		<category><![CDATA[ORDER BY statement]]></category>
		<category><![CDATA[Query optimization]]></category>
		<category><![CDATA[Query performance]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[SQL development]]></category>
		<category><![CDATA[SQL performance]]></category>
		<category><![CDATA[SQL queries]]></category>
		<category><![CDATA[SQL statements]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[Hi, I wanted know as to what I can do to my query so that it improves in performance.RIght now it it taking 3-4 hrs because of the large no of records in the DB.If i remove the group by and order by clause for the same no of records it is fast but when [...]]]></description>
				<content:encoded><![CDATA[<p>Hi,</p>
<p>I wanted know as to what I can do to my query so that it improves in performance.RIght now it it taking 3-4 hrs because of the large no of records in the DB.If i remove the group by and order by clause for the same no of records it is fast but when it does sorting it hangs.But I need to do the sorting a s i am generating a report out of it.Here is my query, note that a lot more conditions are there in the group by and order by claue. I need a quick solution for this. </p>
<p>SELECT A.ACM_AM_ID,B.TCUS_ID,B.CUS_NAME,A.ACM_AC_NUM, A.ACM_ADT_UNIT,C.AAC_USER_ID,F.TFAC_ID,F.FAC_FAC_TYPE,</p>
<p>DECODE(F.FAM_SL_NUM, NULL, &#8221;, F.FAM_SL_NUM), F.FAM_SGD,DECODE(F.FAM_FAM_TYPE, &#8216;AL&#8217;, NVL(F.FAM_NEW_LIMIT, 0) * 10, NVL(F.FAM_NEW_LIMIT, 0)) FAM_NEW_LIMIT ,<br />
FUN_GET_FAC_PURPOSE(F.TFAM_ID, F.FAM_PROD_TYPE), F.FAM_OTH_PURPOSE ,NVL(INTEREST.FPD_SPREAD_RATE, 0,<br />
S.TSIM_ID,<br />
S.SIM_SRTY_TYPE,S.SIM_SRTY_TYPE_OTH,S.SIM_CAT_ASSET,S.SIM_CAT_ASSET_OTH,S.SIM_SGD,W.WIS_ACM_ID, W.WIS_TYPE ,W.WIS_WISSM_FAM_ID PARENT_ID ,W.TFAM_ID CHILD_ID, W.WIS_SGD,<br />
W.WIS_AMT, FAM_LIMIT.AMOUNT ,INTEREST.FPD_INTR_DESC,INTEREST.FPD_VARIANCE </p>
<p>FROM T_ACM_DETAIL A,T_FAM F,T_FAM_WIS_SM W, T_CUS_EMP CE,T_CUS_CORCUS_INFO CU,T_CUS_CUSTOMER B,T_SAM_SECURITY S,</p>
<p>V_LIMIT_BY_ACM FAM_LIMIT, V_FAM_INTEREST INTEREST </p>
<p>WHERE (A.ACM_AM_ID= B.ACM_AM_ID) AND<br />
(FAM_LIMIT.ACM_ADT_ID= A.ACM_AM_ID)  AND<br />
(A.ACM_AM_ID= F.ACM_AM_ID) AND (<br />
 CE.TCUS_ID(+) = B.TCUS_ID) AND<br />
(CU.TCUS_ID(+) = B.TCUS_ID) AND<br />
(B.ACM_AM_ID= F.ACM_AM_ID) AND<br />
(W.TFAM_ID (+) = F.TFAM_ID ) AND<br />
(INTEREST.TFAM_ID (+) = F.TFAM_ID )AND<br />
(S.ACM_AM_IDIS NOT NULL) AND<br />
(A.ACM_AM_ID= S.ACM_AM_ID(+)) AND (B.ACM_AM_ID= S.ACM_AM_ID) </p>
<p>OR </p>
<p>(A.ACM_AM_ID= B.ACM_AM_ID) AND<br />
(FAM_LIMIT.ACM_AM_ID= A.ACM_AM_ID)   AND<br />
(A.ACM_AM_ID= F.ACM_AM_ID) AND<br />
(CE.TCUS_ID(+) = B.TCUS_ID) AND<br />
(CU.TCUS_ID(+) = B.TCUS_ID) AND<br />
(B.ACM_AM_ID= F.ACM_AM_ID) AND<br />
(W.TFAM_ID (+) = F.TFAM_ID ) AND<br />
(INTEREST.TFAM_ID (+) = F.TFAM_ID ) AND<br />
(S.TSIM_ID IS NULL) AND (S.ACM_AM_ID IS NULL) AND (A.ACM_AM_ID= S.ACM_AM_ID(+))  </p>
<p>GROUP BY A.ACM_AM_UNIT,A.ACM_AM_ID,B.TCUS_ID<br />
ORDER BY A.ACM_AM_UNIT,A.ACM_AM_ID,B.TCUS_ID</p>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/itanswers/performance-tuning/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Count several columns Group by accounts Greater than value  Beginner</title>
		<link>http://itknowledgeexchange.techtarget.com/itanswers/count-several-columns-group-by-accounts-greater-than-value-beginner/</link>
		<comments>http://itknowledgeexchange.techtarget.com/itanswers/count-several-columns-group-by-accounts-greater-than-value-beginner/#comments</comments>
		<pubDate>Thu, 17 Apr 2008 22:58:55 +0000</pubDate>
		<dc:creator>Ben Pinto</dc:creator>
				<category><![CDATA[COUNT]]></category>
		<category><![CDATA[GROUP BY statement]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false"></guid>
		<description><![CDATA[I need to be able to count how many values are greater than 1 for each StuNum. I have only been able to count how many values are greater than 1 for each StuNum for d1 or for d2 or for d3, but not for d1, d2 and d3. How can I have it count [...]]]></description>
				<content:encoded><![CDATA[<p>I need to be able to count how many values are greater than 1 for each StuNum.  I have only been able to count how many values are greater than 1 for each StuNum for d1 or for d2 or for d3, but not for d1, d2 and d3.  How can I have it count multiple columns.  </p>
<p>Table</p>
<p>StuNum – SchNum – Tchnum – d1 –  d2 – d3 – d4 – d5 – d6<br />
999999 – 101  &#8211; 4545 &#8211; 1  &#8211; 0 – 2 – 0 – 1 – 3<br />
999999 – 202 – 3636 – 0  &#8211; 1 – 0 –  2 – 1 – 0<br />
444444  &#8211; 202 – 3636 – 0 – 1 &#8211;  0 – 0 – 0 – 1<br />
555555 &#8211;  303  &#8211; 7878 – 0  &#8211; 2 – 3 – 0 – 0 – 1 </p>
<p>SELECT     COUNT(d1) AS Doubles, StuNum, SchNum, TchNum<br />
FROM         table<br />
WHERE     (d1 &gt; 1)<br />
GROUP BY StuNum, SchoolNum, TeachNum</p>
<p>Thanks,</p>
<!-- wpms-network-global-inserts -->]]></content:encoded>
			<wfw:commentRss>http://itknowledgeexchange.techtarget.com/itanswers/count-several-columns-group-by-accounts-greater-than-value-beginner/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</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/9 queries in 0.015 seconds using memcached
Object Caching 524/525 objects using memcached

Served from: itknowledgeexchange.techtarget.com @ 2013-05-18 06:28:31 -->