<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wikidot="http://www.wikidot.com/rss-namespace">

	<channel>
		<title>IDs having more than 1 ORG</title>
		<link>http://www.peoplesoftwiki.com/forum/t-201391/ids-having-more-than-1-org</link>
		<description>Posts in the discussion thread &quot;IDs having more than 1 ORG&quot;</description>
				<copyright></copyright>
		<lastBuildDate>Wed, 08 Feb 2012 21:31:35 +0000</lastBuildDate>
		
					<item>
				<guid>http://www.peoplesoftwiki.com/forum/t-201391#post-1098713</guid>
				<title>(no title)</title>
				<link>http://www.peoplesoftwiki.com/forum/t-201391/ids-having-more-than-1-org#post-1098713</link>
				<description></description>
				<pubDate>Thu, 31 Mar 2011 13:49:46 +0000</pubDate>
				<wikidot:authorName>Mike B</wikidot:authorName>								<content:encoded>
					<![CDATA[
						 <p>I don't really see how. I need to list all of the employees with certain criteria where there are &gt; 1 employees in the department id. I figured, if I did a count and use the partition as an expression, I can get a new field with the count of employees in that dept id. Then I was hoping, i could just do a having clause where that field is &gt; 1. Any other ideas on how to approach if I can't use the count/partition by expression with a having clause? Thanks!</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://www.peoplesoftwiki.com/forum/t-201391#post-1005084</guid>
				<title>(no title)</title>
				<link>http://www.peoplesoftwiki.com/forum/t-201391/ids-having-more-than-1-org#post-1005084</link>
				<description></description>
				<pubDate>Thu, 17 Feb 2011 22:37:12 +0000</pubDate>
				<wikidot:authorName>Praj</wikidot:authorName>				<wikidot:authorUserId>52320</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>I don't think it likes the <tt>PARTITION BY</tt> in your having clause.</p> <p>Can you modify this so you just use <tt>GROUP BY</tt> and <tt>HAVING</tt>?</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://www.peoplesoftwiki.com/forum/t-201391#post-1005021</guid>
				<title>(no title)</title>
				<link>http://www.peoplesoftwiki.com/forum/t-201391/ids-having-more-than-1-org#post-1005021</link>
				<description></description>
				<pubDate>Thu, 17 Feb 2011 21:08:09 +0000</pubDate>
				<wikidot:authorName>Mike b</wikidot:authorName>								<content:encoded>
					<![CDATA[
						 <p>GROUP BY B.COMPANY, C.WW_REGION, C.WW_DISTRICT, B.DEPTID, A.EMPLID, A.NAME, B.JOBCODE, A.BUSINESS_TITLE, A.WW_INC_PROGRAM, TO_CHAR(B.EFFDT,'YYYY-MM-DD'), B.ACTION, B.ACTION_REASON, A.EMPL_STATUS,A.EMPL_RCD<br /> HAVING Count ( A.EMPLID) over (PARTITION BY B.DEPTID) &gt; '1'</p> <p>After I run, I get this error message:</p> <p>Error in running query because of SQL Error, Code=30483, Message=ORA-30483: window functions are not allowed here (50,380)</p> <p>Thanks</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://www.peoplesoftwiki.com/forum/t-201391#post-1003533</guid>
				<title>(no title)</title>
				<link>http://www.peoplesoftwiki.com/forum/t-201391/ids-having-more-than-1-org#post-1003533</link>
				<description></description>
				<pubDate>Wed, 16 Feb 2011 04:25:00 +0000</pubDate>
				<wikidot:authorName>Praj</wikidot:authorName>				<wikidot:authorUserId>52320</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>Hi, can you post the SQL you have generated so far?</p> <p>There are ways to incorporate SQL into PS Query to overcome limitations (e.g. expressions) but sometimes, its just easier to create a view and use that.</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://www.peoplesoftwiki.com/forum/t-201391#post-1003287</guid>
				<title>(no title)</title>
				<link>http://www.peoplesoftwiki.com/forum/t-201391/ids-having-more-than-1-org#post-1003287</link>
				<description></description>
				<pubDate>Tue, 15 Feb 2011 22:10:11 +0000</pubDate>
				<wikidot:authorName>Mike b</wikidot:authorName>								<content:encoded>
					<![CDATA[
						 <p>I am having the same trouble. Any ideas how to build the query in Query manager where I<br /> am not able to write SQL. My query is a little different, but in the end, the logic is the same</p> <p>Thanks!</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://www.peoplesoftwiki.com/forum/t-201391#post-753360</guid>
				<title>Re: IDs having more than 1 ORG</title>
				<link>http://www.peoplesoftwiki.com/forum/t-201391/ids-having-more-than-1-org#post-753360</link>
				<description></description>
				<pubDate>Wed, 14 Apr 2010 20:18:24 +0000</pubDate>
				<wikidot:authorName>mkjj</wikidot:authorName>				<wikidot:authorUserId>410730</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>I removed the effective date part and it still doesn't work. I hate that I can't just write the statement. Thanks for trying to help me. I really appreciate it.</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://www.peoplesoftwiki.com/forum/t-201391#post-705656</guid>
				<title>Re: IDs having more than 1 ORG</title>
				<link>http://www.peoplesoftwiki.com/forum/t-201391/ids-having-more-than-1-org#post-705656</link>
				<description></description>
				<pubDate>Sun, 21 Feb 2010 23:35:08 +0000</pubDate>
				<wikidot:authorName>Praj</wikidot:authorName>				<wikidot:authorUserId>52320</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>It could be the automatic effective date join that's causing the issue? Have you tried taking that out of query to see if you get any results?</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://www.peoplesoftwiki.com/forum/t-201391#post-695684</guid>
				<title>Re: IDs having more than 1 ORG</title>
				<link>http://www.peoplesoftwiki.com/forum/t-201391/ids-having-more-than-1-org#post-695684</link>
				<description></description>
				<pubDate>Tue, 09 Feb 2010 21:03:28 +0000</pubDate>
				<wikidot:authorName>mkjj</wikidot:authorName>								<content:encoded>
					<![CDATA[
						 <p>Here is the SQL that is automatically created. There is an effective date in table 2 that I forgot and it automatically puts in the statement (AND B.EFFDT=……).</p> <p>SELECT DISTINCT A.TERM, A.ID, A.SUBJECT, A.CRSE_NUMBER, A.SECTION, count(distinct B.ORG)<br /> FROM CLASS_VW A, SUBJECT B<br /> WHERE B.SUBJECT = A.SUBJECT<br /> AND B.EFFDT =<br /> (SELECT MAX(B_ED.EFFDT) FROM SUBJECT B_ED<br /> WHERE B.SUBJECT = B_ED.SUBJECT<br /> AND B_ED.EFFDT &lt;= SYSDATE)<br /> AND A.TERM = :1<br /> GROUP BY A.ID, A.TERM, A.SUBJECT, A.CRSE_NUMBER, A.SECTION<br /> HAVING count(distinct B.ORG) &gt; 1</p> <p>Thanks for you help!</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://www.peoplesoftwiki.com/forum/t-201391#post-686480</guid>
				<title>Re: IDs having more than 1 ORG</title>
				<link>http://www.peoplesoftwiki.com/forum/t-201391/ids-having-more-than-1-org#post-686480</link>
				<description></description>
				<pubDate>Thu, 28 Jan 2010 22:50:07 +0000</pubDate>
				<wikidot:authorName>Praj</wikidot:authorName>				<wikidot:authorUserId>52320</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>Would you be able to post the SQL from your PSQuery that you are running please?</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://www.peoplesoftwiki.com/forum/t-201391#post-683726</guid>
				<title>Re: IDs having more than 1 ORG</title>
				<link>http://www.peoplesoftwiki.com/forum/t-201391/ids-having-more-than-1-org#post-683726</link>
				<description></description>
				<pubDate>Mon, 25 Jan 2010 17:42:02 +0000</pubDate>
				<wikidot:authorName>mkjj</wikidot:authorName>								<content:encoded>
					<![CDATA[
						 <p>Sorry it took so long to reply back about the query. The query isn't returning any ids and I know there are ids that have subject\crse number\section with different acad orgs. Any help is appreciated.</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://www.peoplesoftwiki.com/forum/t-201391#post-647857</guid>
				<title>Re: IDs having more than 1 ORG</title>
				<link>http://www.peoplesoftwiki.com/forum/t-201391/ids-having-more-than-1-org#post-647857</link>
				<description></description>
				<pubDate>Fri, 04 Dec 2009 00:31:06 +0000</pubDate>
				<wikidot:authorName>Praj</wikidot:authorName>				<wikidot:authorUserId>52320</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>There's generally two ways to approach this depending on your background:</p> <ol> <li>Think about the scenario in PSQuery and build it in PSQuery</li> <li>Think about the scenario in SQL, write and test in SQL and then <em>replicate</em> the logic in PSQuery</li> </ol> <p>I prefer the second approach, as I think it lets you be more expressive and utilise the full power of SQL. Then the challange isn't how do you write the query, it becomes how to do you make PSQuery generate the SQL…</p> <p>Since I don't have the table/view names, I figure the SQL might look something like this?</p> <div class="code"> <pre> <code>select A.ID, A.SUBJECT, A.CRSE_NUMBER, A.SECTION, count(distinct B.ORG) from TABLE1 A inner join TABLE2 B on A.SUBJECT = B.SUBJECT group by A.ID, A.SUBJECT, A.CRSE_NUMBER, A.SECTION having count(distinct B.ORG) &gt; 1</code> </pre></div> <p>This joins the two tables together on subject, groups by the fields in TABLE1 and then counts the number distinct ORGs in TABLE2 and only returns cases where there is more than 1 distinct ORG.</p> <p>To do this PSQuery:</p> <ul> <li>Add your two tables in the query, standard join on the common fields (e.g. INSTITUTION, SUBJECT)</li> </ul> <ul> <li>Select the appropriate fields you need from TABLE1</li> </ul> <ul> <li>Click on Having, and add the having criteria. You will need to add an expression which is count(distinct B.ACAD_ORG) as an aggregate function so that it generates the correct having SQL. I don't think you can get around this without using an expression. Make it greater than or equal to a constant value of 1.</li> </ul> <ul> <li>Go to expressions and add your expression as a field as well (to list the distinct ORGs)</li> </ul> <p>Here's a screenshot of the expression I think you would need:</p> <table class="wiki-content-table"> <tr> <td><img src="http://www.peoplesoftwiki.com/local--files/forum:thread/ids-more-than-1-org-expression.png" alt="ids-more-than-1-org-expression.png" class="image" /></td> </tr> </table> <p>Here's a screenshot of the having crteria properties you would then use:</p> <table class="wiki-content-table"> <tr> <td><img src="http://www.peoplesoftwiki.com/local--files/forum:thread/ids-more-than-1-org-having-criteria.png" alt="ids-more-than-1-org-having-criteria.png" class="image" /></td> </tr> </table> <p>Note this took a bit of fiddling to get right in PSQuery, hopefully I have the steps right, please reply if you have any problems.</p> 
				 	]]>
				</content:encoded>							</item>
					<item>
				<guid>http://www.peoplesoftwiki.com/forum/t-201391#post-646729</guid>
				<title>IDs having more than 1 ORG</title>
				<link>http://www.peoplesoftwiki.com/forum/t-201391/ids-having-more-than-1-org#post-646729</link>
				<description></description>
				<pubDate>Wed, 02 Dec 2009 18:39:44 +0000</pubDate>
				<wikidot:authorName>mkjj</wikidot:authorName>				<wikidot:authorUserId>410730</wikidot:authorUserId>				<content:encoded>
					<![CDATA[
						 <p>I'm using the Peoplesoft Query reporting tool (version 8.9) and I can't just type a sql statement. I hope I'm giving you all the information needed:</p> <p>2 Tables:</p> <p>table 1</p> <p>ID SUBJECT CRSE_NUMBER SECTION<br /> 1 TEST 500 1<br /> 1 PRP 600 3</p> <p>2 TEST 100 1<br /> 2 TE 100 1</p> <p>3 PRP 200 4<br /> 3 BT 500 1<br /> 3 SD 200 5</p> <p>Joined with table 2 on subject</p> <p>SUBJECT ORG</p> <p>TEST TEST<br /> TE TEST<br /> PRP PRP<br /> BT BTL<br /> SD SDY</p> <p>I need to find all IDs that have more then 1 ORG so it would only retrieve:</p> <p>ID SUBJECT CRSE_NUMBER SECTION<br /> 1 TEST 500 1<br /> 1 PRP 600 3</p> <p>3 PRP 3200 4<br /> 3 BT 4500 1<br /> 3 SD 4200 5</p> <p>Help is appreciated.</p> 
				 	]]>
				</content:encoded>							</item>
				</channel>
</rss>
