SQL Group by issues
Hi All
I am new to SQL .
There are two tables EMP and DEPT . The common column betwee these two is DEPT_NO
Al I am trying to do is display the department name , number of employees and the department's average salary of the employees.
Below id my query . I am not able to complete the query due to the issues that group by clause poses .
Could some one please help ?
SELECT DEPT.DEPT_NAME , SUM(EMP.EMP_NO) , AVG(EMP.SAL)
FROM EMP , DEPT
WHERE EMP.DEPT_NO = DEPT.DEPT_NO
GROUP BY DEPT.DEPT_NAME
Thanks
Guna
user9967723 wrote:
I want to display the employee name, department number, and all the employees that work in the same department .This seems very different from your original request.
Also please let me know where i can find a 'attachment link in this page' to attach the table snap shot. You cannot attach anything in this forum. Creating a text version would be the most helpful as some external sites that host images are blocked for some of the users here.
It is always helpful to provide the following:
1. Oracle version (SELECT * FROM V$VERSION)
2. Sample data in the form of CREATE / INSERT statements.
3. Expected output
4. Explanation of expected output (A.K.A. "business logic")
5. Use \ tags for #2 and #3. See FAQ (Link on top right side) for details.
Also see the third post in this thread:
{thread:id=2174552}
Similar Messages
-
Dear All,
I have a result set like this
A
UK
A
USA
A
Canada
B
Canada
B
UK
I need a query that can give me results like this
A
UK
USA
B
Canada
UK
Any help would be greatly appreciated
cheers,
SammyThanks for your reply. But I want the results to be like this
A
UK
USA
Canada
B
Australia
Germany
Like all the resuts of A should be combined into one row. and same is with B right now when I run the query It looks like this:
A
UK
null
USA
null
Canada
B
Australia
null
Germany
Thank you for your help in advance -
SQL query performance issues.
Hi All,
I worked on the query a month ago and the fix worked for me in test intance but failed in production. Following is the URL for the previous thread.
SQL query performance issues.
Following is the tkprof file.
CURSOR_ID:76 LENGTH:2383 ADDRESS:f6b40ab0 HASH_VALUE:2459471753 OPTIMIZER_GOAL:ALL_ROWS USER_ID:443 (APPS)
insert into cos_temp(
TRX_DATE, DEPT, PRODUCT_LINE, PART_NUMBER,
CUSTOMER_NUMBER, QUANTITY_SOLD, ORDER_NUMBER,
INVOICE_NUMBER, EXT_SALES, EXT_COS,
GROSS_PROFIT, ACCT_DATE,
SHIPMENT_TYPE,
FROM_ORGANIZATION_ID,
FROM_ORGANIZATION_CODE)
select a.trx_date,
g.segment5 dept,
g.segment4 prd,
m.segment1 part,
d.customer_number customer,
b.quantity_invoiced units,
-- substr(a.sales_order,1,6) order#,
substr(ltrim(b.interface_line_attribute1),1,10) order#,
a.trx_number invoice,
(b.quantity_invoiced * b.unit_selling_price) sales,
(b.quantity_invoiced * nvl(price.operand,0)) cos,
(b.quantity_invoiced * b.unit_selling_price) -
(b.quantity_invoiced * nvl(price.operand,0)) profit,
to_char(to_date('2010/02/28 00:00:00','yyyy/mm/dd HH24:MI:SS'),'DD-MON-RR') acct_date,
'DRP',
l.ship_from_org_id,
p.organization_code
from ra_customers d,
gl_code_combinations g,
mtl_system_items m,
ra_cust_trx_line_gl_dist c,
ra_customer_trx_lines b,
ra_customer_trx_all a,
apps.oe_order_lines l,
apps.HR_ORGANIZATION_INFORMATION i,
apps.MTL_INTERCOMPANY_PARAMETERS inter,
apps.HZ_CUST_SITE_USES_ALL site,
apps.qp_list_lines_v price,
apps.mtl_parameters p
where a.trx_date between to_date('2010/02/01 00:00:00','yyyy/mm/dd HH24:MI:SS')
and to_date('2010/02/28 00:00:00','yyyy/mm/dd HH24:MI:SS')+0.9999
and a.batch_source_id = 1001 -- Sales order shipped other OU
and a.complete_flag = 'Y'
and a.customer_trx_id = b.customer_trx_id
and b.customer_trx_line_id = c.customer_trx_line_id
and a.sold_to_customer_id = d.customer_id
and b.inventory_item_id = m.inventory_item_id
and m.organization_id
= decode(substr(g.segment4,1,2),'01',5004,'03',5004,
'02',5003,'00',5001,5002)
and nvl(m.item_type,'0') <> '111'
and c.code_combination_id = g.code_combination_id+0
and l.line_id = b.interface_line_attribute6
and i.organization_id = l.ship_from_org_id
and p.organization_id = l.ship_from_org_id
and i.org_information3 <> '5108'
and inter.ship_organization_id = i.org_information3
and inter.sell_organization_id = '5108'
and inter.customer_site_id = site.site_use_id
and site.price_list_id = price.list_header_id
and product_attr_value = to_char(m.inventory_item_id)
call count cpu elapsed disk query current rows misses
Parse 1 0.47 0.56 11 197 0 0 1
Execute 1 3733.40 3739.40 34893 519962154 11 188 0
total 2 3733.87 3739.97 34904 519962351 11 188 1
| Rows Row Source Operation
| ------------ ---------------------------------------------------
| 188 HASH JOIN (cr=519962149 pr=34889 pw=0 time=2607.35)
| 741 .TABLE ACCESS BY INDEX ROWID QP_PRICING_ATTRIBUTES (cr=519939426 pr=34889 pw=0 time=2457.32)
| 254644500 ..NESTED LOOPS (cr=519939265 pr=34777 pw=0 time=3819.67)
| 254643758 ...NESTED LOOPS (cr=8921833 pr=29939 pw=0 time=1274.41)
| 741 ....NESTED LOOPS (cr=50042 pr=7230 pw=0 time=11.37)
| 741 .....NESTED LOOPS (cr=48558 pr=7229 pw=0 time=11.35)
| 741 ......NESTED LOOPS (cr=47815 pr=7223 pw=0 time=11.32)
| 3237 .......NESTED LOOPS (cr=41339 pr=7223 pw=0 time=12.42)
| 3237 ........NESTED LOOPS (cr=38100 pr=7223 pw=0 time=12.39)
| 3237 .........NESTED LOOPS (cr=28296 pr=7139 pw=0 time=12.29)
| 1027 ..........NESTED LOOPS (cr=17656 pr=4471 pw=0 time=3.81)
| 1027 ...........NESTED LOOPS (cr=13537 pr=4404 pw=0 time=3.30)
| 486 ............NESTED LOOPS (cr=10873 pr=4240 pw=0 time=0.04)
| 486 .............NESTED LOOPS (cr=10385 pr=4240 pw=0 time=0.03)
| 486 ..............TABLE ACCESS BY INDEX ROWID RA_CUSTOMER_TRX_ALL (cr=9411 pr=4240 pw=0 time=0.02)
| 75253 ...............INDEX RANGE SCAN RA_CUSTOMER_TRX_N5 (cr=403 pr=285 pw=0 time=0.38)
| 486 ..............TABLE ACCESS BY INDEX ROWID HZ_CUST_ACCOUNTS (cr=974 pr=0 pw=0 time=0.01)
| 486 ...............INDEX UNIQUE SCAN HZ_CUST_ACCOUNTS_U1 (cr=488 pr=0 pw=0 time=0.01)
| 486 .............INDEX UNIQUE SCAN HZ_PARTIES_U1 (cr=488 pr=0 pw=0 time=0.01)
| 1027 ............TABLE ACCESS BY INDEX ROWID RA_CUSTOMER_TRX_LINES_ALL (cr=2664 pr=164 pw=0 time=1.95)
| 2063 .............INDEX RANGE SCAN RA_CUSTOMER_TRX_LINES_N2 (cr=1474 pr=28 pw=0 time=0.22)
| 1027 ...........TABLE ACCESS BY INDEX ROWID RA_CUST_TRX_LINE_GL_DIST_ALL (cr=4119 pr=67 pw=0 time=0.54)
| 1027 ............INDEX RANGE SCAN RA_CUST_TRX_LINE_GL_DIST_N1 (cr=3092 pr=31 pw=0 time=0.20)
| 3237 ..........TABLE ACCESS BY INDEX ROWID MTL_SYSTEM_ITEMS_B (cr=10640 pr=2668 pw=0 time=15.35)
| 3237 ...........INDEX RANGE SCAN MTL_SYSTEM_ITEMS_B_U1 (cr=2062 pr=40 pw=0 time=0.33)
| 3237 .........TABLE ACCESS BY INDEX ROWID OE_ORDER_LINES_ALL (cr=9804 pr=84 pw=0 time=0.77)
| 3237 ..........INDEX UNIQUE SCAN OE_ORDER_LINES_U1 (cr=6476 pr=47 pw=0 time=0.43)
| 3237 ........TABLE ACCESS BY INDEX ROWID MTL_PARAMETERS (cr=3239 pr=0 pw=0 time=0.04)
| 3237 .........INDEX UNIQUE SCAN MTL_PARAMETERS_U1 (cr=2 pr=0 pw=0 time=0.01)
| 741 .......TABLE ACCESS BY INDEX ROWID HR_ORGANIZATION_INFORMATION (cr=6476 pr=0 pw=0 time=0.10)
| 6474 ........INDEX RANGE SCAN HR_ORGANIZATION_INFORMATIO_FK2 (cr=3239 pr=0 pw=0 time=0.03)Please help.
Regards
Ashish| 254644500 ..NESTED LOOPS (cr=519939265 pr=34777 pw=0 time=3819.67)
| 254643758 ...NESTED LOOPS (cr=8921833 pr=29939 pw=0 time=1274.41)There is no way the optimizer should choose to process that many rows using nested loops.
Either the statistics are not up to date, the data values are skewed or you have some optimizer parameter set to none default to force index access.
Please post explain plan and optimizer* parameter settings. -
SQL Developer connection issue with JDBC
Hi skutz & friends,
I have problem with Oracle SQL Developer I can not connect to any oracle db
because Status : Failure -Error loading native JDBC driver library.
However, I download SQL developer [ Oracle SQL Developer for Windows (JDK1.5.0_06 is bundled in this zip) ]
After it is not working. Also I download JDK 5.0 Update 14
The Java SE Development Kit (JDK) to install it on my PC again.
But it does not work. My install path information:
install path as C:\Program Files\SQLDEVELOPER_INSTAL\sqldeveloper
local oracle as !0g 10201
SQL version as sqldeveloper-1.2.1.3213 which download last versionfrom OTN on 2/18/2008.
for connection, taken basic.
port as default 1521
hostname and saver name are same.
I created a environment variable in window xp.
SQLDEVELOPER_USER_DIR AS C:\Program Files\SQLDEVELOPER_INSTAL\sqldeveloper
can anybody help me with this connection?
thanks
JimmyDuplicate thread: Please enter all responses on other thread: SQL seveloper connection issue with JDBC
-
How to connect to SQL*Plus and issue a query all in one command?
Hi everyone,
Does anyone know of a way to connect to a db with SQL*Plus, and issue a simple query, all with one command?
I know that I can save a .sql script with a query, then do this:
sqlplus user/pwd@db @myscript.sql
But I'm wondering if there's any way to put the actual query right into the connect command, something like:
sqlplus user/pwd@db "select count(*) from dba_tables;"
Does anyone know of a way to do this?you didn't mention windows or unix. so, here's a link with both
Re: windows sql script
it also has a link to another thread on how to deal with the parens when using ehco in dos. -
New sessions every time an sql statement is issued
Hi, I have a problem with using oraoledb (v 10.1.0) with VB6 accessing an Oracle database 9i (v 9.2.0.6). Every time an sql statement is issued in the client side, a new session is started in the server side (seen in Enterprise Manager). I don´'t know why. Is an oraoledb parameter or a database parameter? How can I avoid this? The big problem behind this behaviour is controling row locking. If I issue a "select field from table where conditions for update nowait(or wait n)", this creates a lock that belongs to a session. If a few sentences after I issue an "update the-same-table set the-same-field = value where the-same-condition" as this one creates a new session, an ORA-00054 is raised telling the row(s) is blocked.
any idea?
thanksI'm a DBA and I encountered the same problem with a system developed for our company. We reported that to the company that developed the application and they sey then close the conections, but they remain in the database.
Could anyone find a solution for this? I believe is a problem in the VB code, but I do not know anything from VB.
thanks,
Lisandro -
Please help: WebLogic + BI + SQL Group Authenticator
Hi all, i have big problem with solution on my company project. I please somebody help me.
This is my problem:
I have bifoundation_domain :
WebLogic Server Version: 10.3.5.0
EM 11g
Oracle Business Intelligence 11.1.1.7.0
with this structure:
bifoundation_domain
|- AdminServer
|- bi_cluster
|- bi_server1
So and i need use Weblogic embedded LDAP (DefaultAuthenticator in realms security providers) and i need loading GROUPS from DATABASE. I read and tried a lot of articles, blogs, manuals but
within positive result.
My procedure is:
In WLS console :
- create jdbc datasource with name "bip_apps_DS"
- create BI SQL Group provider (with name BIGroupLoader) with this settings
<sec:authentication-provider xmlns:ext="http://xmlns.oracle.com/weblogic/security/extension" xsi:type="ext:bisql-group-providerType">
<sec:name>BIGroupLoader</sec:name>
<sec:control-flag>OPTIONAL</sec:control-flag>
<ext:data-source-jndi-name>bip_apps_DS</ext:data-source-jndi-name>
<ext:sql-list-member-groups>SELECT ROLE_NAME FROM V_SYS_AUTH_ROLES WHERE LOGIN_NAME = ?</ext:sql-list-member-groups>
<ext:sql-list-groups>SELECT NAME FROM UA_ROLES WHERE NAME LIKE ?</ext:sql-list-groups>
<ext:sql-group-exists>SELECT NAME FROM UA_ROLES WHERE NAME = ?</ext:sql-group-exists>
<ext:sql-is-member>SELECT LOGIN_NAME FROM V_SYS_AUTH_ROLES WHERE ROLE_NAME = ? AND LOGIN_NAME = ?</ext:sql-is-member>
<ext:sql-get-group-description>SELECT DESCRIPTION FROM UA_ROLES WHERE NAME = ?</ext:sql-get-group-description>
</sec:authentication-provider>
(my DB schema is correct)
and i move him on first place in providers list.
So after these steps in WLS console i see in security realm->groups my groups from DB. Everything is OK.
Now i need use GROUPS from my database in EM in the context of create BI users roles (maping BI application roles on GROUPS (enterprise roles)).
So i created a database adapter for the Virtualized Identity Store
this is it:
<?xml version = '1.0' encoding = 'UTF-8'?>
<adapters schvers="303" version="1" xmlns="http://www.octetstring.com/schemas/Adapters" xmlns:adapters="http://www.w3.org/2001/XMLSchema-instance">
<dataBase id="directoryType" version="0">
<root>%ROOT%</root>
<active>true</active>
<serverType>directoryType</serverType>
<routing>
<critical>true</critical>
<priority>50</priority>
<inclusionFilter/>
<exclusionFilter/>
<plugin/>
<retrieve/>
<store/>
<visible>Yes</visible>
<levels>-1</levels>
<bind>true</bind>
<bind-adapters/>
<views/>
<dnpattern/>
</routing>
<pluginChains xmlns="http://xmlns.oracle.com/iam/management/ovd/config/plugins">
<plugins>
<plugin>
<name>VirtualAttribute</name>
<class>oracle.ods.virtualization.engine.chain.plugins.virtualattr.VirtualAttributePlugin</class>
<initParams>
<param name="ReplaceAttribute" value="uniqueMember={cn=%uniquemember%,ou=people,ou=myrealm,dc=bifoundation_domain}"/>
</initParams>
</plugin>
</plugins>
<default>
<plugin name="VirtualAttribute"/>
</default>
<add/>
<bind/>
<delete/>
<get/>
<modify/>
<rename/>
</pluginChains>
<driver>oracle.jdbc.driver.OracleDriver</driver>
<url>%URL%</url>
<user>%USER%</user>
<password>%PASSWORD%</password>
<ignoreObjectClassOnModify>false</ignoreObjectClassOnModify>
<includeInheritedObjectClasses>true</includeInheritedObjectClasses>
<maxConnections>10</maxConnections>
<mapping>
<joins/>
<objectClass name="groupofuniquenames" rdn="cn">
<attribute ldap="cn" table="V_SYS_AUTH_ROLES" field="ROLE_NAME" type=""/>
<attribute ldap="description" table="V_SYS_AUTH_ROLES" field="ROLE_NAME" type=""/>
<attribute ldap="uniquemember" table="V_SYS_AUTH_ROLES" field="LOGIN_NAME" type=""/>
</objectClass>
</mapping>
<useCaseInsensitiveSearch>true</useCaseInsensitiveSearch>
<connectionWaitTimeout>10</connectionWaitTimeout>
<oracleNetConnectTimeout>0</oracleNetConnectTimeout>
<validateConnection>false</validateConnection>
</dataBase>
</adapters>
and run command to register:
./libovdadapterconfig.sh -adapterName BIGroupLoader -adapterTemplate bi_sql_groups_adapter_template.xml
-host localhost -port 7001 -userName weblogic -domainPath /OFM/BI/user_projects/domains/bifoundation_domain
-dataStore DB -root ou=people,ou=myrealm,dc=bifoundation_domain -contextName default -dataSourceJNDIName bip_apps_DS
Adapter is creatted successfully within errors!
I restarted managed server(bi_server1) and AdminServer, all bi commponets etc. BUT WITHOUT RESULT. I still dont see GROUPS in Enterprise manager in
BI->coreapplication->security->application roles
I tried set in security setting of webLogic domain in EM virtualize=true.
This procedure is described on all sites but not funkcionaly for me. Do you know somebody where is mistake? Etc. need i installing OVD server? I dont know. Please helm me. after 10 days i really hopeless :( ..so sorry for my englishIf you are still looking for sol? send me email [email protected]
-
Please help: WebLogic + BI + Bi SQl Group Loader
Hi all, i have big problem with solution on my company project. I please somebody help me.
This is my problem:
I have bifoundation_domain :
WebLogic Server Version: 10.3.5.0
EM 11g
Oracle Business Intelligence 11.1.1.7.0
with this structure:
bifoundation_domain
|- AdminServer
|- bi_cluster
|- bi_server1
So and i need use Weblogic embedded LDAP (DefaultAuthenticator in realms security providers) and i need loading GROUPS from DATABASE. I read and tried a lot of articles, blogs, manuals but
within positive result.
My procedure is:
In WLS console :
- create jdbc datasource with name "bip_apps_DS"
- create BI SQL Group provider (with name BIGroupLoader) with this settings
<sec:authentication-provider xmlns:ext="http://xmlns.oracle.com/weblogic/security/extension" xsi:type="ext:bisql-group-providerType">
<sec:name>BIGroupLoader</sec:name>
<sec:control-flag>OPTIONAL</sec:control-flag>
<ext:data-source-jndi-name>bip_apps_DS</ext:data-source-jndi-name>
<ext:sql-list-member-groups>SELECT ROLE_NAME FROM V_SYS_AUTH_ROLES WHERE LOGIN_NAME = ?</ext:sql-list-member-groups>
<ext:sql-list-groups>SELECT NAME FROM UA_ROLES WHERE NAME LIKE ?</ext:sql-list-groups>
<ext:sql-group-exists>SELECT NAME FROM UA_ROLES WHERE NAME = ?</ext:sql-group-exists>
<ext:sql-is-member>SELECT LOGIN_NAME FROM V_SYS_AUTH_ROLES WHERE ROLE_NAME = ? AND LOGIN_NAME = ?</ext:sql-is-member>
<ext:sql-get-group-description>SELECT DESCRIPTION FROM UA_ROLES WHERE NAME = ?</ext:sql-get-group-description>
</sec:authentication-provider>
(my DB schema is correct)
and i move him on first place in providers list.
So after these steps in WLS console i see in security realm->groups my groups from DB. Everything is OK.
Now i need use GROUPS from my database in EM in the context of create BI users roles (maping BI application roles on GROUPS (enterprise roles)).
So i created a database adapter for the Virtualized Identity Store
this is it:
<?xml version = '1.0' encoding = 'UTF-8'?>
<adapters schvers="303" version="1" xmlns="http://www.octetstring.com/schemas/Adapters" xmlns:adapters="http://www.w3.org/2001/XMLSchema-instance">
<dataBase id="directoryType" version="0">
<root>%ROOT%</root>
<active>true</active>
<serverType>directoryType</serverType>
<routing>
<critical>true</critical>
<priority>50</priority>
<inclusionFilter/>
<exclusionFilter/>
<plugin/>
<retrieve/>
<store/>
<visible>Yes</visible>
<levels>-1</levels>
<bind>true</bind>
<bind-adapters/>
<views/>
<dnpattern/>
</routing>
<pluginChains xmlns="http://xmlns.oracle.com/iam/management/ovd/config/plugins">
<plugins>
<plugin>
<name>VirtualAttribute</name>
<class>oracle.ods.virtualization.engine.chain.plugins.virtualattr.VirtualAttributePlugin</class>
<initParams>
<param name="ReplaceAttribute" value="uniqueMember={cn=%uniquemember%,ou=people,ou=myrealm,dc=bifoundation_domain}"/>
</initParams>
</plugin>
</plugins>
<default>
<plugin name="VirtualAttribute"/>
</default>
<add/>
<bind/>
<delete/>
<get/>
<modify/>
<rename/>
</pluginChains>
<driver>oracle.jdbc.driver.OracleDriver</driver>
<url>%URL%</url>
<user>%USER%</user>
<password>%PASSWORD%</password>
<ignoreObjectClassOnModify>false</ignoreObjectClassOnModify>
<includeInheritedObjectClasses>true</includeInheritedObjectClasses>
<maxConnections>10</maxConnections>
<mapping>
<joins/>
<objectClass name="groupofuniquenames" rdn="cn">
<attribute ldap="cn" table="V_SYS_AUTH_ROLES" field="ROLE_NAME" type=""/>
<attribute ldap="description" table="V_SYS_AUTH_ROLES" field="ROLE_NAME" type=""/>
<attribute ldap="uniquemember" table="V_SYS_AUTH_ROLES" field="LOGIN_NAME" type=""/>
</objectClass>
</mapping>
<useCaseInsensitiveSearch>true</useCaseInsensitiveSearch>
<connectionWaitTimeout>10</connectionWaitTimeout>
<oracleNetConnectTimeout>0</oracleNetConnectTimeout>
<validateConnection>false</validateConnection>
</dataBase>
</adapters>
and run command to register:
./libovdadapterconfig.sh -adapterName BIGroupLoader -adapterTemplate bi_sql_groups_adapter_template.xml
-host localhost -port 7001 -userName weblogic -domainPath /OFM/BI/user_projects/domains/bifoundation_domain
-dataStore DB -root ou=people,ou=myrealm,dc=bifoundation_domain -contextName default -dataSourceJNDIName bip_apps_DS
Adapter is creatted successfully within errors!
I restarted managed server(bi_server1) and AdminServer, all bi commponets etc. BUT WITHOUT RESULT. I still dont see GROUPS in Enterprise manager in
BI->coreapplication->security->application roles
I tried set in security setting of webLogic domain in EM virtualize=true.
This procedure is described on all sites but not funkcionaly for me. Do you know somebody where is mistake? Etc. need i installing OVD server? I dont know. Please helm me.Hi,
You will not be able to see groups that you have defined in database in EM. To assign a database group to a role in EM go to BI->coreapplication->security->application roles & search for groups locate Advance Option at the bottom and check the box "Check to enter principal name here instead of searching from above. This option can be used for advanced scenarios related to custom authenticators". Now select Groups under Type and enter the name (exactly same) of the database group manually. Now you should be able to assign database groups to users authenticated through weblogic embedded LDAP.
Thanks -
Required info on SQL Server Performance Issue Analysis and Troubleshoot way
Dear All,
I am going to prepare the simple documentation steps on SQL Server Performance Issue Analysis and troubleshoot method. I am struggling to make this documentation since we have different checklist (like network latency,disk latency, memory/processor pressure,SQL
query tuning etc) to validate once application performance issue reported from the customer.So, I am looking for the experts document or link sharing .
Your input will help for document preparation in better way.
Thanks in advance.Hi,
Recommendations and Guidelines on configuring disk partitions for SQL Server
http://support.microsoft.com/kb/2023571
Disk and File Layout for SQL Server
https://blogs.technet.com/b/dataplatforminsider/archive/2012/12/19/disk-and-file-layout-for-sql-server.aspx
Microsoft SQL Server 2012 Performance Tuning: Implementing Physical Database Structure
http://www.packtpub.com/article/sql-server-2012-implementing-physical-database-strusture
Database Mirroring Best Practices and Performance Considerations
http://technet.microsoft.com/en-us/library/cc917681.aspx
Hope the information helps.
Tracy Cai
TechNet Community Support -
To enable filtering the Purchase Orders based on Purchasing Group in Issue
Hi All,
We are facing one issue
Currently we are working with Extended Classic Scenario with SRM 5.0 and support pack 11
If the buyer uses Issue PO transaction in SRM, there are POs from all the buyers.
There is no filter to allow the buyer to display only POs relevant for his/her Purchasing group.
To enable filtering the Purchase Orders based on Purchasing Group in Issue Purchase Order transction, we found one
OSS note : 1162884 - BBP_PPF: Purchasing group as search criteria for PO
But we found that this oss note is not applicable for our system version
Could you please help me to resolve this issue by any suggestion or by any other oss note?
Thanks
SnehalHi Snehal,
There is a easy way to do that.
Go to buyer role in PFCG transaction and look for profile and go inside profile ...look for your transaction...
for Process PO transaction - BBP_PD_PO and you have field BBP_PURGRP...using which you can restrict it on purchasing group..
You may have to copy same role and create new roles based on purchasing group..
I feel that basis or Security and Authorization team can help you in this matter.
Regards,Nishant -
I've tried going through the steps to resolve the issue, but I am still coming up blank. The part that I am not understanding is the, "A non-recoverable error occurred during a database lookup." part.
Is this a security problem? I can establish an ODBC connection to the server as well as connect and query through visual studio, however when trying to run it through one of our custom programs, it throws this error message.
A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider:
TCP Provider, error: 0 - A non-recoverable error occurred during a database lookup.)There are many reasons of SQL server connectivity issue. Refer checklist to find out the real cause of connectivity issue.
1. Check SQL services are running
2. Check SQL Browser service is running
3. Check remote connections are enabled
4. Network connectivity between database & application servers by TRACERT command
5. Check TCP/IP protocol enabled at SQL server
6. Check talent connectivity – telnet <IP address> <port no on SQL server running>
7. Check UDP port 1434 is open or not on SQL Server
8. Check firewall is running or not Check
9. If firewall running, SQL Server & UDP port must be added in exception in firewall
10. Run SQL Discovery report on machine SQL server installed, to check you are using correct instance name to connect( default \named) -http://mssqlfun.com/2013/02/26/sql-server-discovery-report/
http://mssqlfun.com/2012/09/28/check-list-for-sql-server-connectivity-issue/
Regards,
Rohit Garg
(My Blog)
This posting is provided with no warranties and confers no rights.
Please remember to click Mark as Answer and Vote as Helpful on posts that help you. This can be beneficial to other community members reading the thread. -
SQL Query Group By Issues - Urgent
I currently have an issue writing a pl\sql report, I can get part of the way to the results I want but the group by clause is causing problems, because I have to add more columns to the group by, dispersing the figures further, I have tried it with coalesce for each of the task types but I still get the same results, I am getting close to the results I need but not quite there yet. I would really appreciate it if someone could take at look at this for me as it is an urgent requirement.
The report is based on the tables similar to the following:
TASKS, ORGANISATIONS, POSITIONS
A position is a member of an organisation.
A task has a position assigned to it.
The SQL for the tables and to insert the data that would produce the report is detailed below:
CREATE TABLE TASKS
( TASK_ID NUMBER NOT NULL ENABLE,
TASK_TYPE VARCHAR2 (15 BYTE) NOT NULL ENABLE,
STATUS VARCHAR2 (15 BYTE) NOT NULL ENABLE,
POS_ID NUMBER NOT NULL ENABLE,
CONSTRAINT TASKS_PK PRIMARY KEY (TASK_ID));
CREATE TABLE ORGANISATIONS
( ORG_ID NUMBER NOT NULL ENABLE,
ORG_NAME VARCHAR2 (15 BYTE) NOT NULL ENABLE,
CONSTRAINT ORGANISATIONS_PK PRIMARY KEY (ORG_ID));
CREATE TABLE POSITIONS
( POS_ID NUMBER NOT NULL ENABLE,
POS_NAME VARCHAR2 (25 BYTE) NOT NULL ENABLE,
ORG_ID NUMBER NOT NULL ENABLE,
CONSTRAINT POSITIONS_PK PRIMARY KEY (POS_ID));
INSERT INTO ORGANISATIONS (ORG_ID, ORG_NAME) VALUES (1,'ABC');
INSERT INTO ORGANISATIONS (ORG_ID, ORG_NAME) VALUES (2,'DEF');
INSERT INTO ORGANISATIONS (ORG_ID, ORG_NAME) VALUES (3,'EFG');
INSERT INTO POSITIONS (POS_ID, POS_NAME, ORG_ID) VALUES (1,'ABC-1', 1);
INSERT INTO POSITIONS (POS_ID, POS_NAME, ORG_ID) VALUES (3,'ABC-2', 1);
INSERT INTO POSITIONS (POS_ID, POS_NAME, ORG_ID) VALUES (2,'ABC-3', 1);
INSERT INTO POSITIONS (POS_ID, POS_NAME, ORG_ID) VALUES (5,'DEF-2', 2);
INSERT INTO POSITIONS (POS_ID, POS_NAME, ORG_ID) VALUES (4,'DEF-1', 2);
INSERT INTO POSITIONS (POS_ID, POS_NAME, ORG_ID) VALUES (7,'EFG-1', 3);
INSERT INTO TASKS (TASK_ID, TASK_TYPE, STATUS, POS_ID) VALUES (12,'TASK_TYPE_3','LIVE',3);
INSERT INTO TASKS (TASK_ID, TASK_TYPE, STATUS, POS_ID) VALUES (11,'TASK_TYPE_2','LIVE',3);
INSERT INTO TASKS (TASK_ID, TASK_TYPE, STATUS, POS_ID) VALUES (10,'TASK_TYPE_2','LIVE',2);
INSERT INTO TASKS (TASK_ID, TASK_TYPE, STATUS, POS_ID) VALUES (9,'TASK_TYPE_2','LIVE',2);
INSERT INTO TASKS (TASK_ID, TASK_TYPE, STATUS, POS_ID) VALUES (8,'TASK_TYPE_1','LIVE',3);
INSERT INTO TASKS (TASK_ID, TASK_TYPE, STATUS, POS_ID) VALUES (7,'TASK_TYPE_1','LIVE',3);
INSERT INTO TASKS (TASK_ID, TASK_TYPE, STATUS, POS_ID) VALUES (6,'TASK_TYPE_1','LIVE',3);
INSERT INTO TASKS (TASK_ID, TASK_TYPE, STATUS, POS_ID) VALUES (5,'TASK_TYPE_1','LIVE',3);
INSERT INTO TASKS (TASK_ID, TASK_TYPE, STATUS, POS_ID) VALUES (4,'TASK_TYPE_1','LIVE',2);
INSERT INTO TASKS (TASK_ID, TASK_TYPE, STATUS, POS_ID) VALUES (3,'TASK_TYPE_3','LIVE',1);
INSERT INTO TASKS (TASK_ID, TASK_TYPE, STATUS, POS_ID) VALUES (2,'TASK_TYPE_1','LIVE',1);
INSERT INTO TASKS (TASK_ID, TASK_TYPE, STATUS, POS_ID) VALUES (1,'TASK_TYPE_1','LIVE',1);
INSERT INTO TASKS (TASK_ID, TASK_TYPE, STATUS, POS_ID) VALUES (13,'TASK_TYPE_3','LIVE',3);
The report should detail the following information based on the information in the tables:
1st Column
Organisation
ABC
DEF
EFG
2nd Column
No. of Positions in Organsiation
3
2
1
With total of the number of people in all of the organisation 6
3rd Column
Number of tasks assigned to the organisation of task type1
2
1
4
4th Column
Number of tasks assigned to the organisation of task type 2
0
2
1
5th Column
Number of tasks assigned to the organisation of task type 3
1
0
2
Total no of tasks assigned to the Organisation
3
3
7
Message was edited by:
Suzy_r_82
Message was edited by:
Suzy_r_82Hi,
Apologies, my insert statements where incorrect, if you try the data below instead it should give you output I was expecting
INSERT INTO TASKS( TASK_ID, TASK_TYPE, STATUS, POS_ID) VALUES (1,'TASK_TYPE_1', 'LIVE',1);
INSERT INTO TASKS( TASK_ID, TASK_TYPE, STATUS, POS_ID) VALUES (2,'TASK_TYPE_1', 'LIVE',2);
INSERT INTO TASKS( TASK_ID, TASK_TYPE, STATUS, POS_ID) VALUES (3,'TASK_TYPE_1', 'LIVE',5);
INSERT INTO TASKS( TASK_ID, TASK_TYPE, STATUS, POS_ID) VALUES (4,'TASK_TYPE_1', 'LIVE',7);
INSERT INTO TASKS( TASK_ID, TASK_TYPE, STATUS, POS_ID) VALUES (5,'TASK_TYPE_1', 'LIVE',7);
INSERT INTO TASKS( TASK_ID, TASK_TYPE, STATUS, POS_ID) VALUES (6,'TASK_TYPE_1', 'LIVE',7);
INSERT INTO TASKS( TASK_ID, TASK_TYPE, STATUS, POS_ID) VALUES (7,'TASK_TYPE_1', 'LIVE',7);
INSERT INTO TASKS( TASK_ID, TASK_TYPE, STATUS, POS_ID) VALUES (8,'TASK_TYPE_2', 'LIVE',4);
INSERT INTO TASKS( TASK_ID, TASK_TYPE, STATUS, POS_ID) VALUES (9,'TASK_TYPE_2', 'LIVE',5);
INSERT INTO TASKS( TASK_ID, TASK_TYPE, STATUS, POS_ID) VALUES (10,'TASK_TYPE_3', 'LIVE',1);
INSERT INTO TASKS( TASK_ID, TASK_TYPE, STATUS, POS_ID) VALUES (11,'TASK_TYPE_3', 'LIVE',7);
INSERT INTO TASKS( TASK_ID, TASK_TYPE, STATUS, POS_ID) VALUES (12,'TASK_TYPE_2', 'LIVE',7);
INSERT INTO TASKS( TASK_ID, TASK_TYPE, STATUS, POS_ID) VALUES (13,'TASK_TYPE_3', 'LIVE',7);
The results I would like are
ORG No. of Pos No of Task No of Task No of Task Total no
In Org Type1 for Type2 for Type3 for of Tasks
Org Org Org for Org
ABC 3 2 0 1 3
DEF 2 1 2 0 3
EFG 1 4 1 2 7
Total 6The results I get are multiple lines for each organisation, I would like to rollup these lines so I can have one line per organisation.
Hope this helps a bit more, I appreciate the help, let me know if you need more information
Thanks
Suzy -
SQL Statement -- Throws GROUP BY issue on NVL
Hey All,
This is pretty much my first time tackling a very complex SQL Statement but the boss is adamant about it.
Anyways here is the information. I have 3 Tables. Table one Contains Work Order Infromation that will be listed or grouped. Table 2 and Table 3 house information that needs to be summed (Estimate hours and Actual Hours).
So my SQL Statement looked something like this... (Its a mess)
select workorder.wolo3, workorder.wojp1, workorder.wonum, workorder.description, workorder.location, workorder.status, workorder.wopriority, workorder.targstartdate, workorder.reportdate, workorder.pmnum, workorder.schedstart, sum(labtrans.regularhrs + labtrans.premiumpayhours) as actualhours, sum(wplabor.quantity * wplabor.laborhrs) as estimatehrs
from maximo.workorder left outer join maximo.labtrans on labtrans.regularhrs > 0 and labtrans.refwo = workorder.wonum and labtrans.siteid = workorder.siteid or labtrans.premiumpayratetype = 'MULTIPLIER' and labtrans.refwo = workorder.wonum and labtrans.siteid = workorder.siteid left outer join maximo.wplabor on wplabor.wonum = workorder.wonum and wplabor.siteid = workorder.siteid
where workorder.istask=0 and workorder.siteid='NTS' and workorder.status in ('INPRG','SCHED') and workorder.crewid in ('MAINT','DAF') and workorder.schedstart <= TO_DATE('12-13-2009','MM-DD-YYYY') and wolo3 is not null group by workorder.wonum, workorder.status, workorder.wopriority, workorder.pmnum, workorder.location, workorder.description, workorder.targstartdate, workorder.reportdate, workorder.schedstart, workorder.wolo3, workorder.wojp1
Now the problem is that the 2nd sum (Estimate Hrs) gets HUGE numbers if there are multiple rows in Actual Hours. So I did some searching. Seems that if I used the NVL function in the SQL Statement it would fix the issue...
select workorder.wolo3, workorder.wojp1, workorder.wonum, workorder.description, workorder.location, workorder.status, workorder.wopriority, workorder.targstartdate, workorder.reportdate, workorder.pmnum, workorder.schedstart, sum(labtrans.regularhrs + labtrans.premiumpayhours) as actualhours,
nvl((select sum(wplabor.quantity * wplabor.laborhrs) from maximo.wplabor where wplabor.wonum = workorder.wonum and wplabor.siteid = workorder.siteid),0)
from maximo.workorder left outer join maximo.labtrans on labtrans.regularhrs > 0 and labtrans.refwo = workorder.wonum and
labtrans.siteid = workorder.siteid or labtrans.premiumpayratetype = 'MULTIPLIER' and labtrans.refwo = workorder.wonum and
labtrans.siteid = workorder.siteid
where workorder.istask=0 and workorder.siteid='NTS' and workorder.status in ('INPRG','SCHED') and
workorder.crewid in ('MAINT','DAF') and workorder.schedstart <= TO_DATE('12-13-2009','MM-DD-YYYY') and wolo3 is not null
group by workorder.wonum, workorder.status, workorder.wopriority, workorder.pmnum, workorder.location, workorder.description, workorder.targstartdate, workorder.reportdate, workorder.schedstart, workorder.wolo3, workorder.wojp1
However If get the error not a GROUP BY expression.
I really need this to work. How can I get the NVL to work with out having to define a Group for it. The problem is that it is a "alias column" and you cannot Group by those fields. Frustation sets in... UGH!
Thanks in Advance, Ben.Hi, Ben,
Wlecome to the forum!
user12273726 wrote:
So my SQL Statement looked something like this... (Its a mess)You're right. Fix that first.
Put each SELECT item, each condition, and each GROUP BY expression on a separate line. Indent to show here the clauses (SELECT, FROM, WHERE) are.
For example:
SELECT workorder.wolo3
, workorder.wojp1
, workorder.wonum
, workorder.description
, workorder.location
, workorder.status
, workorder.wopriority
, workorder.targstartdate
, workorder.reportdate
, workorder.pmnum
, workorder.schedstart
, SUM (labtrans.regularhrs + labtrans.premiumpayhours) AS actualhours
, SUM (wplabor.quantity * wplabor.laborhrs) AS estimatehrs
FROM maximo.workorder
LEFT OUTER JOIN maximo.labtrans ON labtrans.regularhrs > 0
AND labtrans.refwo = workorder.wonum
AND labtrans.siteid = workorder.siteid
OR labtrans.premiumpayratetype = 'MULTIPLIER' -- WARNING! Don't mix AND and OR
AND labtrans.refwo = workorder.wonum
AND labtrans.siteid = workorder.siteid
LEFT OUTER JOIN maximo.wplabor ON wplabor.wonum = workorder.wonum
AND wplabor.siteid = workorder.siteid
WHERE workorder.istask = 0
AND workorder.siteid = 'NTS'
AND workorder.status IN ('INPRG','SCHED')
AND workorder.crewid IN ('MAINT','DAF')
AND workorder.schedstart <= TO_DATE ('12-13-2009','MM-DD-YYYY')
AND wolo3 IS NOT NULL
GROUP BY workorder.wonum
, workorder.status
, workorder.wopriority
, workorder.pmnum
, workorder.location
, workorder.description
, workorder.targstartdate
, workorder.reportdate
, workorder.schedstart
, workorder.wolo3
, workorder.wojp1
;When you post formatted text on this site, type these 6 characters:
{code}
(small letters only, inside curly brackets) before and after sections of formatted text, to preserve spacing.
Now the problem is that the 2nd sum (Estimate Hrs) gets HUGE numbers if there are multiple rows in Actual Hours. Huge numbers are not necessarily wrong. Do yo mean the numbers computed by your query are much bigger than they are supposed to be?
So I did some searching. Seems that if I used the NVL function in the SQL Statement it would fix the issue...
select workorder.wolo3, workorder.wojp1, workorder.wonum, workorder.description, workorder.location, workorder.status, workorder.wopriority, workorder.targstartdate, workorder.reportdate, workorder.pmnum, workorder.schedstart, sum(labtrans.regularhrs + labtrans.premiumpayhours) as actualhours,
nvl((select sum(wplabor.quantity * wplabor.laborhrs) from maximo.wplabor where wplabor.wonum = workorder.wonum and wplabor.siteid = workorder.siteid),0)
...It looks like you have a Chasm Trap, where you have multiple, independent one-to-many relationships on the same table, and the solution to aggregate them in separate queruies.
It looks like you're trying to aggregate wplabor in scalar sub-queries, which makes the GROUP BY more complicated (as you discovered), and is also very inefficient.
It would be easier to code and more efficient to run if you aggregated wplabor in a sub-query, and then joined to this sub-query (and not the actual wplabor table) in your main query.
If you'd like help, post a little sample data (CREATE TABLE and INSERT statements) for all three tables, and the results you want from that data.
Simplify as much as possible. Instead of GROUPing BY 11 columns, just GROUP BY, say, 3 columns: the 2 involved in the join condidiotns, and one more. Once you understand how to do this, adding the other expressions will be trivial.
You can also simplify by ignoring, for now, the WHERE clause, and, therefore, the columns involved in the WHERE clause. It looks like that has nothing to do with the problem. Again, adding the conditions later will be trivial. -
SQL: GROUP BY and UNION addition issue..
I'm looking to to get the TOTALS of the grouping. What I'm getting now is either a 1 or a 2 whether or not each PRIMARY_ASSIGMENT_GROUP appears in each query. when I run the
SELECT a.PRIMARY_ASSIGNMENT_GROUP,GROUP(a.PRIMARY_ASSIGNMENT_GROUP) from
SELECT
COUNT(PRIMARY_ASSIGNMENT_GROUP),PRIMARY_ASSIGNMENT_GROUP
from
SMINCREQ
LEFT JOIN SMOPERATOR on SMINCREQ.OPENED_BY=SMOPERATOR.NAME
WHERE
open_time BETWEEN to_date(:P246_SDATEB,'DD-MON-YYYY') AND to_date(:P246_EDATEB,'DD-MON-YYYY') and
((to_char(CAST((FROM_TZ(CAST(open_time AS TIMESTAMP),'+00:00') AT TIME ZONE 'US/Eastern') AS DATE),'HH24') between '00' and '08') or (to_char(CAST((FROM_TZ(CAST(open_time AS TIMESTAMP),'+00:00') AT TIME ZONE 'US/Eastern') AS DATE),'HH24') between '19' and '24')) GROUP BY PRIMARY_ASSIGNMENT_GROUP
UNION ALL
SELECT
COUNT(PRIMARY_ASSIGNMENT_GROUP),PRIMARY_ASSIGNMENT_GROUP
from SMINTERACTIONS
WHERE
open_time BETWEEN to_date(:P246_SDATEB,'DD-MON-YYYY') AND to_date(:P246_EDATEB,'DD-MON-YYYY') and
((to_char(CAST((FROM_TZ(CAST(open_time AS TIMESTAMP),'+00:00') AT TIME ZONE 'US/Eastern') AS DATE),'HH24') between '00' and '08') or (to_char(CAST((FROM_TZ(CAST(open_time AS TIMESTAMP),'+00:00') AT TIME ZONE 'US/Eastern') AS DATE),'HH24') between '19' and '24')) GROUP BY PRIMARY_ASSIGNMENT_GROUP
) a
GROUP BY (a.PRIMARY_ASSIGNMENT_GROUP)
ORDER by COUNT(a.PRIMARY_ASSIGNMENT_GROUP)bostonmacosx wrote:
I'm looking to to get the TOTALS of the grouping. What I'm getting now is either a 1 or a 2 whether or not each PRIMARY_ASSIGMENT_GROUP appears in each query. when I run the
SELECT a.PRIMARY_ASSIGNMENT_GROUP,GROUP(a.PRIMARY_ASSIGNMENT_GROUP) from
SELECT
COUNT(PRIMARY_ASSIGNMENT_GROUP),PRIMARY_ASSIGNMENT_GROUP
from
SMINCREQ
LEFT JOIN SMOPERATOR on SMINCREQ.OPENED_BY=SMOPERATOR.NAME
WHERE
open_time BETWEEN to_date(:P246_SDATEB,'DD-MON-YYYY') AND to_date(:P246_EDATEB,'DD-MON-YYYY') and
((to_char(CAST((FROM_TZ(CAST(open_time AS TIMESTAMP),'+00:00') AT TIME ZONE 'US/Eastern') AS DATE),'HH24') between '00' and '08') or (to_char(CAST((FROM_TZ(CAST(open_time AS TIMESTAMP),'+00:00') AT TIME ZONE 'US/Eastern') AS DATE),'HH24') between '19' and '24')) GROUP BY PRIMARY_ASSIGNMENT_GROUP
UNION ALL
SELECT
COUNT(PRIMARY_ASSIGNMENT_GROUP),PRIMARY_ASSIGNMENT_GROUP
from SMINTERACTIONS
WHERE
open_time BETWEEN to_date(:P246_SDATEB,'DD-MON-YYYY') AND to_date(:P246_EDATEB,'DD-MON-YYYY') and
((to_char(CAST((FROM_TZ(CAST(open_time AS TIMESTAMP),'+00:00') AT TIME ZONE 'US/Eastern') AS DATE),'HH24') between '00' and '08') or (to_char(CAST((FROM_TZ(CAST(open_time AS TIMESTAMP),'+00:00') AT TIME ZONE 'US/Eastern') AS DATE),'HH24') between '19' and '24')) GROUP BY PRIMARY_ASSIGNMENT_GROUP
) a
GROUP BY (a.PRIMARY_ASSIGNMENT_GROUP)
ORDER by COUNT(a.PRIMARY_ASSIGNMENT_GROUP)Instead of using UNION ALL you should be able to get by with GROUPING SETS or ROLLUP.
If you'd care to put together a small test case with data (representing what you have) and some sample output (what you need) along with your Oracle version
select * from v$versionI'm sure someone will help you out.
Cheers, -
Hi friends,
I am struck on a issue for which i am trying to find a solution. The issue is i have a select statement which returns me the data like below. The first column is the date column, the second and third column represent the count based on the column 4 and column 5. i.e, column 2 is mapped based on col4 and col3 is mapped to col5. I want the data in the table to be grouped based on the col4 and col5.
Existing table
Date col2 col3 col4 col5
2010-07-25 3 7 26 26
2010-07-25 3 3 26 505
2010-07-25 1 7 505 26
2010-07-25 1 3 505 505
Desired table
Date col2 col3 col4 col5
2010-07-25 3 7 26 26
2010-07-25 1 3 505 505
Could you please let me know how to do it.
Note: Topic is moved to SQL/PLSQL forum
Edited by: bluerose on Aug 20, 2011 1:53 AMfor the data provided it seems just
... where col4 = col 5or reading the requirement maybe (NOT TESTED!)
select x.date,x.col2,y.col3,x.col4,y.col5
from (select max(date) date,max(col2) col2,col4
group by col4
) x,
(select max(date) date,max(col3) col3,col5
group by col5
) y
where x.col4 = y.col5Regards
Etbin
Maybe you are looking for
-
Hi All, I am just trying to deploy my sample Portal Project Application from NWDS through Quick PAR upload into Portal Server, this is the first time i am getting this error, i don't know why The error is like below PAR upload failed: i did a
-
Cursor query works in anonymous block but not in procedure
Hello, My cursor query works fine in anonymous blcok but fails in pl/sql block. Anonymous block: declare cursor c1 is select object_name from all_objects where owner='IRIS_DATA' and object_type='SEQUENCE'; v_string varchar2(2000); begin for c2 in c1
-
How do I turn off double-spacing in Mail
Whenever I compose a message in Mail, if I hit the return key, it skips down two lines at one time. How do I get a single space?
-
Triggering mail with pdf attachment in PO workflow
I have a requirement that when PO is changed in ME22N or if new PO is created then Workflow will be triggered and mail is send with the PO details as .pdf file and is send to either the PO creator or PO changer in his SAP inbox. Can anybody help me w
-
How to identify default browser through a 'C' program on solaris 8
I have a requirement to display a html page in the default browser installed on solaris 8 machine through a C program. through a C program, 1. How to identify the default browser installed on a solaris machine? 2 How to get the path of the default br