SQL statement Help Find County
I have an Oracle table with lot of columns and I want to check if 3 of my columns contain all values (I don't like the real value, there, I just want to know how many of them have a value). Allows so say for example:Table columns: ID, A, B, C
These conditions would be true... value exists in both A AND B, A AND C or B AND C columns. If a value exists in A and not B or C, then it should not be counted. Similarly, if a value exists in B and not A or C, or there is a value C and not A or B, then he shouldn't have counted.
----------------------
| ID | A | B | C |
----------------------
| 1. X | X | | <-true
| 1. X | X | X | <-true
| 1. X | | X | <-true
| 1 | | X | X | <-true
| 1. X | | | <-false
| 1 | | X | | <-false
| 1 | | | X | <-false
| 1 | | | | <-false
| 2. X | X | | <-true
| 2. X | X | X | <-true
| 2. X | | X | <-true
| 2 | | X | X | <-true
| 2. X | | | <-false
| 2 | | X | | <-false
| 2 | | | X | <-false
| 2 | | | | <-false
----------------------
Static values will be my ID. I want to check against 2 ID who I know will always be the case. I tried to write, but I'm sure I'm doing something wrong because my count was very high (about 1.7 million records over 2 million).
That's what I wrote:
Select count (*)
FROM table1
where (ID = "1" or ID = "2")
(A is not null and B is not null)
or (A is not null and is not null)
or (B is not null and is not null);
Thanks for your help!
Published by: 973560 on March 14, 2013 12:03
Hello
One way to see how many rows have values in at least 2 of the following columns:
SELECT COUNT (*) AS cnt
FROM table1
WHERE id IN ('1', '2') -- is id really a string?
AND NVL2 (a, 1, 0)
+ NVL2 (b, 1, 0)
+ NVL2 (c, 1, 0) >= 2
;
I hope that answers your question.
If not, post a small example data (CREATE TABLE and only relevant columns, INSERT statements) and also publish outcomes from these data.
Point where the above query is to produce erroneous results, and explain, using specific examples, how you get the right results from data provided in the palces.
Always say what version of Oracle you are using (for example, 11.2.0.2.0).
See the FAQ forum {message identifier: = 9360002}
Tags: Database
Similar Questions
-
SQL Query help find albums from sale
Hi Experts,
I have the following data and the need to find the book Top sold in each type.
Book Type QTY
20 Help the 3 10 Kitchen 1 5 Navigation 2 30 Help the 4 Please let me how can know we get this simple SQL help?
Thank you
Bharat
Hello
Bharat Hegde wrote:
Hi all
I tried to use Dense_rank as below. But it gives me the top selling books. I need high library in each type...
This looks like a job for 'PARTITION BY type
For example:
WITH got_rnk AS
(
SELECT b.bid, b.type
SUM (o.quantity) AS total_quantity
DENSE_RANK () OVER ( PARTITION BY b.type
ORDER OF SUM (o.quantity) / / DESC
) AS rnk
B BOOK
o order1
WHERE b.bid = o.bid
GROUP BY b.bid, b.type
)
SELECT total_quantity, type submission
OF got_rnk
WHERE rnk = 1
;
. Aggregate functions (such as the SUM, above) are calculated before analytical functions, so an analytic function (such as DENSE_RANK above) may depend on an aggregate function; you don't need a separate subquery for that.
-
create a dynamic help based on a sql statement
Hello
A few years ago, I asked the same question, but I had no adequate answer to my problem:
I have to build a text of dynamic help for items diaplayed (bubble help or better pop-up window). When I go to a header element there is a? Displays and when I click on the left mouse button it will be a constant display text. Now, I have a table with explanation (build on documentation in the table) for each column on each page. If I want to start an SQL statement when I click the button and the text should be displayed in the pop-up window.
An example everywhere or can someone help me otherways?
Concerning
Siegwin
fixed for you, the changes are:
- added onclick = "getItemHelpText('#CURRENT_ITEM_NAME#'); call to your model of 'Optional with Help' for all items using this model will have the same call in.
- adding the global page, page 0,
- moved JavaScript "getItemHelpText" on page 0 to become a global function, so you can use it anywhere in the application
- added item globle P0_DYNAMIC_HELP_TEXT page 0
- update your application process to set the value of P0_DYNAMIC_HELP_TEXT on the convening of AJAX, you must fix the help text.
- help text changed to P41_ENAME in & P0_DYNAMIC_HELP_TEXT.
That's all I think, tested worked.
good luck with the rest...
-
Hello. all.
I wonder how to find sql_id using a sql statement, including transport retrun and tab space multiple.
To be more precise,
My sql is:
Select
col_a,
col_b,
..
..
I usually use the following query to find the sql_id
Select sql_id in v$ sql where sql_text like 'MY SQL STATEMENT %.
When MY SQL STATEMENT includes carriage return and tab space multiple, how can I do?
Thanks in advance.
Best regards.Hello
Did you look at regular expressions? Use regexp_like instead of as.
http://www.Stanford.edu/dept/ITSS/docs/Oracle/10G/server.101/b10759/conditions018.htm
Kind regards
-
Help with a SQL statement...
Hello...
I have tried to find a way to write a SQL statement and may not seem to produce something that works. What I need is a set of results that returns each month that a given task is in an open State. The only columns that I have in my work table with are TASK_NM, OPEN_DT and CLOSED_DT.
So if I have a line containing the following: TASK_NM = 'task one', OPEN_DT = April 18, 10 ' and CLOSED_DT = 14 October 10 '... I would like to see as a result set that looks like:
TASK_NM YEAR JAN FEB MAR APR MAY JUNE JULY AUG SEP OCT NOV DEC
the task of a 2010 0 0 0 1 1 1 1 1 1 1 0 0
Is it still possible?
Thanks in advance,
David.
Published by: user13027968 on March 10, 2011 14:19
Published by: user13027968 on March 10, 2011 15:13Hello
Welcome to the Forum!
Whenever you have a question. Please post a small example of data (CREATE TABLE and INSERT statements) and the results desired from these data.
For example, the sample data may be:CREATE TABLE table_x ( task_nm VARCHAR2 (10) , open_dt DATE , closed_dt DATE ); INSERT INTO table_x (task_nm, open_dt, closed_dt) VALUES ('task a', DATE '2010-04-18', DATE '2010-10-14'); INSERT INTO table_x (task_nm, open_dt, closed_dt) VALUES ('foo', DATE '2010-10-31', DATE '2011-01-01'); INSERT INTO table_x (task_nm, open_dt, closed_dt) VALUES ('foo', DATE '2010-12-01', DATE '2011-02-21'); INSERT INTO table_x (task_nm, open_dt, closed_dt) VALUES ('foo', DATE '2011-04-01', DATE '2011-04-30'); INSERT INTO table_x (task_nm, open_dt, closed_dt) VALUES ('bar', DATE '2010-01-01', DATE '2010-01-01');
From this data, you may want these results:
TASK_NM YEAR JAN FEB MAR APR MAY JUN JUL AUG SEP OVT NOV DEC ---------- ----- --- --- --- --- --- --- --- --- --- --- --- --- bar 2010 1 0 0 0 0 0 0 0 0 0 0 0 foo 2010 0 0 0 0 0 0 0 0 0 1 1 1 foo 2011 1 1 0 1 0 0 0 0 0 0 0 0 task a 2010 0 0 0 1 1 1 1 1 1 1 0 0
I'm not sure eactly how you plan to use it. Are there lines that overlap for the name of the task? You always want the same number of columns? What version of Oracle are you using?
I think you want something like this:WITH got_month_cnt AS ( SELECT task_nm , TRUNC (open_dt, 'MONTH') AS first_month , 1 + MONTHS_BETWEEN ( TRUNC (closed_dt, 'MONTH') , TRUNC (open_dt, 'MONTH') ) AS month_cnt FROM table_x -- WHERE ... -- If you want any filtering, put it here ) , cntr AS ( SELECT LEVEL AS n FROM ( SELECT MAX (month_cnt) AS max_month_cnt FROM got_month_cnt ) CONNECT BY LEVEL <= max_month_cnt ) , all_months AS ( SELECT m.task_nm , ADD_MONTHS ( m.first_month , c.n - 1 ) AS open_month FROM got_month_cnt m JOIN cntr c ON c.n <= m.month_cnt ) SELECT task_nm , EXTRACT (YEAR FROM open_month) AS year , MAX (CASE WHEN TO_CHAR (open_month, 'Mon') = 'Jan' THEN 1 ELSE 0 END) AS jan , MAX (CASE WHEN TO_CHAR (open_month, 'Mon') = 'Feb' THEN 1 ELSE 0 END) AS feb , MAX (CASE WHEN TO_CHAR (open_month, 'Mon') = 'Mar' THEN 1 ELSE 0 END) AS mar , MAX (CASE WHEN TO_CHAR (open_month, 'Mon') = 'Apr' THEN 1 ELSE 0 END) AS apr , MAX (CASE WHEN TO_CHAR (open_month, 'Mon') = 'May' THEN 1 ELSE 0 END) AS may , MAX (CASE WHEN TO_CHAR (open_month, 'Mon') = 'Jun' THEN 1 ELSE 0 END) AS jun , MAX (CASE WHEN TO_CHAR (open_month, 'Mon') = 'Jul' THEN 1 ELSE 0 END) AS jul , MAX (CASE WHEN TO_CHAR (open_month, 'Mon') = 'Aug' THEN 1 ELSE 0 END) AS aug , MAX (CASE WHEN TO_CHAR (open_month, 'Mon') = 'Sep' THEN 1 ELSE 0 END) AS sep , MAX (CASE WHEN TO_CHAR (open_month, 'Mon') = 'Oct' THEN 1 ELSE 0 END) AS ovt , MAX (CASE WHEN TO_CHAR (open_month, 'Mon') = 'Nov' THEN 1 ELSE 0 END) AS nov , MAX (CASE WHEN TO_CHAR (open_month, 'Mon') = 'Dec' THEN 1 ELSE 0 END) AS dec FROM all_months GROUP BY task_nm , EXTRACT (YEAR FROM open_month) ORDER BY task_nm , year ;
This will work in Orfacle 9 (and), but from Oracle 11, you could simplify it a little bit by using SELECT... Function PIVOT.
Published by: Frank Kulash, March 10, 2011 16:51
-
Need help to resolve the error - below the SQL statement to execute cannot be
Below is my CO as, which creates a callable statement.
try {}
OAApplicationModule oaapplicationmodule = (webBean) pageContext.getApplicationModule;
OADBTransactionImpl t = (OADBTransactionImpl) oaapplicationmodule.getOADBTransaction ();
OracleCallableStatement proc = (OracleCallableStatement) t.createCallableStatement (lquery,-1);
proc. Execute();
t.Commit ();
}
catch (SQLException sqlexception)
{
throw OAException.wrapperException (sqlexception);
}
After the execution of the page, get the below error... (Please find below stack error)
I have referred the development guide but did not get something useful.
Please give me clues about the same.
Raghu cordially
-- Error Stack ---------------------------------------------------------
Error page
Details of the exception.
oracle.apps.fnd.framework.OAException: oracle.jbo.SQLStmtException: Houston-27123: SQL error in the preparation of the call statement. Statement: null
at oracle.apps.fnd.framework.OAException.wrapperException(OAException.java:888)
at oracle.apps.fnd.framework.webui.OAPageErrorHandler.prepareException(OAPageErrorHandler.java:1145)
at oracle.apps.fnd.framework.webui.OAPageErrorHandler.processErrors(OAPageErrorHandler.java:1408)
at oracle.apps.fnd.framework.webui.OAPageBean.processFormRequest(OAPageBean.java:2637)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:1659)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:497)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:418)
in OA. jspService(OA.jsp:40)
at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:56)
at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:317)
at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:465)
at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:379)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:727)
at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:306)
at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:767)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:259)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:106)
to EDU.oswego.cs.dl.util.concurrent.PooledExecutor$ Worker.run (PooledExecutor.java:803)
at java.lang.Thread.run(Thread.java:534)
# # 0 in detail
java.sql.SQLException: the SQL statement to execute cannot be empty or null
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:269)
at oracle.jdbc.driver.OracleConnection.privatePrepareCall(OracleConnection.java:1138)
at oracle.jdbc.driver.OracleConnection.prepareCall(OracleConnection.java:1054)
at oracle.jbo.server.DBTransactionImpl.createCallableStatement(DBTransactionImpl.java:3033)
at cisco.oracle.apps.xxchr.element.server.webui.XXCHRElementSetSearchCO.processFormRequest(XXCHRElementSetSearchCO.java:343)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(OAWebBeanHelper.java:799)
at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(OAWebBeanContainerHelper.java:363)
at oracle.apps.fnd.framework.webui.OAPageLayoutHelper.processFormRequest(OAPageLayoutHelper.java:1118)
at oracle.apps.fnd.framework.webui.beans.layout.OAPageLayoutBean.processFormRequest(OAPageLayoutBean.java:1579)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:995)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:961)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(OAWebBeanHelper.java:816)
at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(OAWebBeanContainerHelper.java:363)
at oracle.apps.fnd.framework.webui.beans.form.OAFormBean.processFormRequest(OAFormBean.java:395)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:995)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:961)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(OAWebBeanHelper.java:816)
at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(OAWebBeanContainerHelper.java:363)
at oracle.apps.fnd.framework.webui.beans.OABodyBean.processFormRequest(OABodyBean.java:363)
at oracle.apps.fnd.framework.webui.OAPageBean.processFormRequest(OAPageBean.java:2633)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:1659)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:497)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:418)
in OA. jspService(OA.jsp:40)
at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:56)
at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:317)
at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:465)
at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:379)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:727)
at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:306)
at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:767)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:259)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:106)
to EDU.oswego.cs.dl.util.concurrent.PooledExecutor$ Worker.run (PooledExecutor.java:803)
at java.lang.Thread.run(Thread.java:534)
java.sql.SQLException: the SQL statement to execute cannot be empty or null
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:134)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:179)
at oracle.jdbc.dbaccess.DBError.throwSqlException(DBError.java:269)
at oracle.jdbc.driver.OracleConnection.privatePrepareCall(OracleConnection.java:1138)
at oracle.jdbc.driver.OracleConnection.prepareCall(OracleConnection.java:1054)
at oracle.jbo.server.DBTransactionImpl.createCallableStatement(DBTransactionImpl.java:3033)
at cisco.oracle.apps.xxchr.element.server.webui.XXCHRElementSetSearchCO.processFormRequest(XXCHRElementSetSearchCO.java:343)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(OAWebBeanHelper.java:799)
at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(OAWebBeanContainerHelper.java:363)
at oracle.apps.fnd.framework.webui.OAPageLayoutHelper.processFormRequest(OAPageLayoutHelper.java:1118)
at oracle.apps.fnd.framework.webui.beans.layout.OAPageLayoutBean.processFormRequest(OAPageLayoutBean.java:1579)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:995)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:961)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(OAWebBeanHelper.java:816)
at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(OAWebBeanContainerHelper.java:363)
at oracle.apps.fnd.framework.webui.beans.form.OAFormBean.processFormRequest(OAFormBean.java:395)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:995)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequestChildren(OAWebBeanHelper.java:961)
at oracle.apps.fnd.framework.webui.OAWebBeanHelper.processFormRequest(OAWebBeanHelper.java:816)
at oracle.apps.fnd.framework.webui.OAWebBeanContainerHelper.processFormRequest(OAWebBeanContainerHelper.java:363)
at oracle.apps.fnd.framework.webui.beans.OABodyBean.processFormRequest(OABodyBean.java:363)
at oracle.apps.fnd.framework.webui.OAPageBean.processFormRequest(OAPageBean.java:2633)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:1659)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:497)
at oracle.apps.fnd.framework.webui.OAPageBean.preparePage(OAPageBean.java:418)
in OA. jspService(OA.jsp:40)
at com.orionserver.http.OrionHttpJspPage.service(OrionHttpJspPage.java:56)
at oracle.jsp.runtimev2.JspPageTable.service(JspPageTable.java:317)
at oracle.jsp.runtimev2.JspServlet.internalService(JspServlet.java:465)
at oracle.jsp.runtimev2.JspServlet.service(JspServlet.java:379)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)
at com.evermind.server.http.ServletRequestDispatcher.invoke(ServletRequestDispatcher.java:727)
at com.evermind.server.http.ServletRequestDispatcher.forwardInternal(ServletRequestDispatcher.java:306)
at com.evermind.server.http.HttpRequestHandler.processRequest(HttpRequestHandler.java:767)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:259)
at com.evermind.server.http.HttpRequestHandler.run(HttpRequestHandler.java:106)
to EDU.oswego.cs.dl.util.concurrent.PooledExecutor$ Worker.run (PooledExecutor.java:803)
at java.lang.Thread.run(Thread.java:534)
Published by: Rambeau on Oct 14, 2010 02:58check the code stuck by me again
Connection Conn = pageContext.getApplicationModule (webBean) .getOADBTransaction () .getJdbcConnection ();
Connection conn = oaapplicationmodule.getOADBTransaction().getJdbcConnection(); //Right one
Thank you
-Anil -
With the help of a number variable in a SQL statement
Hello
I am trying to use a variable in a sql statement, and I ran into problems when the variable is a number. The following line of code works if the variable is a string, but not if it is a number.
"SELECT PAGE 1 UUT_STATUS OF UNIT_UUT_RESULT WHERE UnitID = '" + Locals.LocalUnitID + "' ORDER BY DESC START_DATE_TIME.
Is there a difference in the use of single and double quotes and the sign for numbers variables +?
Thank you
Stuart
Jervin is almost correct in the post above.
While it is correct that numbers in SQL are not enclosed in single quotes ('), we still need the entire expression to a string. If Locals.LocalUnitID is stored as a number to TestStand, you will need to cast to a string so that the string concatination works properly.
I believe that the correct form is as follows:
"SELECT PAGE 1 UUT_STATUS OF UNIT_UUT_RESULT WHERE UnitID ="+ Str (Locals.LocalUnitID) + 'ORDER BY DESC START_DATE_TIME'
-
I need help in the sql statement
Hi all
im working in the hr schema
I need sql statement to answer my question
I need information to all employees
where average wage = average wage department 50
Sorry I can't speak English very well
I thank allThere is no need to do so in the two motions. All you need is:
select * from ( select e.*, avg(case department_id when 50 then salary end) over() dept_50_avg_sal from hr.employees e ) where salary <= dept_50_avg_sal / EMPLOYEE_ID FIRST_NAME LAST_NAME EMAIL PHONE_NUMBER HIRE_DATE JOB_ID SALARY COMMISSION_PCT MANAGER_ID DEPARTMENT_ID DEPT_50_AVG_SAL ----------- -------------------- ------------------------- ------------------------- -------------------- --------- ---------- ---------- -------------- ---------- ------------- --------------- 198 Donald OConnell DOCONNEL 650.507.9833 21-JUN-07 SH_CLERK 2600 124 50 3475.55556 199 Douglas Grant DGRANT 650.507.9844 13-JAN-08 SH_CLERK 2600 124 50 3475.55556 115 Alexander Khoo AKHOO 515.127.4562 18-MAY-03 PU_CLERK 3100 114 30 3475.55556 116 Shelli Baida SBAIDA 515.127.4563 24-DEC-05 PU_CLERK 2900 114 30 3475.55556 117 Sigal Tobias STOBIAS 515.127.4564 24-JUL-05 PU_CLERK 2800 114 30 3475.55556 118 Guy Himuro GHIMURO 515.127.4565 15-NOV-06 PU_CLERK 2600 114 30 3475.55556 119 Karen Colmenares KCOLMENA 515.127.4566 10-AUG-07 PU_CLERK 2500 114 30 3475.55556 125 Julia Nayer JNAYER 650.124.1214 16-JUL-05 ST_CLERK 3200 120 50 3475.55556 126 Irene Mikkilineni IMIKKILI 650.124.1224 28-SEP-06 ST_CLERK 2700 120 50 3475.55556 127 James Landry JLANDRY 650.124.1334 14-JAN-07 ST_CLERK 2400 120 50 3475.55556 128 Steven Markle SMARKLE 650.124.1434 08-MAR-08 ST_CLERK 2200 120 50 3475.55556 EMPLOYEE_ID FIRST_NAME LAST_NAME EMAIL PHONE_NUMBER HIRE_DATE JOB_ID SALARY COMMISSION_PCT MANAGER_ID DEPARTMENT_ID DEPT_50_AVG_SAL ----------- -------------------- ------------------------- ------------------------- -------------------- --------- ---------- ---------- -------------- ---------- ------------- --------------- 129 Laura Bissot LBISSOT 650.124.5234 20-AUG-05 ST_CLERK 3300 121 50 3475.55556 130 Mozhe Atkinson MATKINSO 650.124.6234 30-OCT-05 ST_CLERK 2800 121 50 3475.55556 131 James Marlow JAMRLOW 650.124.7234 16-FEB-05 ST_CLERK 2500 121 50 3475.55556 132 TJ Olson TJOLSON 650.124.8234 10-APR-07 ST_CLERK 2100 121 50 3475.55556 133 Jason Mallin JMALLIN 650.127.1934 14-JUN-04 ST_CLERK 3300 122 50 3475.55556 134 Michael Rogers MROGERS 650.127.1834 26-AUG-06 ST_CLERK 2900 122 50 3475.55556 135 Ki Gee KGEE 650.127.1734 12-DEC-07 ST_CLERK 2400 122 50 3475.55556 136 Hazel Philtanker HPHILTAN 650.127.1634 06-FEB-08 ST_CLERK 2200 122 50 3475.55556 138 Stephen Stiles SSTILES 650.121.2034 26-OCT-05 ST_CLERK 3200 123 50 3475.55556 139 John Seo JSEO 650.121.2019 12-FEB-06 ST_CLERK 2700 123 50 3475.55556 140 Joshua Patel JPATEL 650.121.1834 06-APR-06 ST_CLERK 2500 123 50 3475.55556 EMPLOYEE_ID FIRST_NAME LAST_NAME EMAIL PHONE_NUMBER HIRE_DATE JOB_ID SALARY COMMISSION_PCT MANAGER_ID DEPARTMENT_ID DEPT_50_AVG_SAL ----------- -------------------- ------------------------- ------------------------- -------------------- --------- ---------- ---------- -------------- ---------- ------------- --------------- 142 Curtis Davies CDAVIES 650.121.2994 29-JAN-05 ST_CLERK 3100 124 50 3475.55556 143 Randall Matos RMATOS 650.121.2874 15-MAR-06 ST_CLERK 2600 124 50 3475.55556 144 Peter Vargas PVARGAS 650.121.2004 09-JUL-06 ST_CLERK 2500 124 50 3475.55556 180 Winston Taylor WTAYLOR 650.507.9876 24-JAN-06 SH_CLERK 3200 120 50 3475.55556 181 Jean Fleaur JFLEAUR 650.507.9877 23-FEB-06 SH_CLERK 3100 120 50 3475.55556 182 Martha Sullivan MSULLIVA 650.507.9878 21-JUN-07 SH_CLERK 2500 120 50 3475.55556 183 Girard Geoni GGEONI 650.507.9879 03-FEB-08 SH_CLERK 2800 120 50 3475.55556 186 Julia Dellinger JDELLING 650.509.3876 24-JUN-06 SH_CLERK 3400 121 50 3475.55556 187 Anthony Cabrio ACABRIO 650.509.4876 07-FEB-07 SH_CLERK 3000 121 50 3475.55556 190 Timothy Gates TGATES 650.505.3876 11-JUL-06 SH_CLERK 2900 122 50 3475.55556 191 Randall Perkins RPERKINS 650.505.4876 19-DEC-07 SH_CLERK 2500 122 50 3475.55556 EMPLOYEE_ID FIRST_NAME LAST_NAME EMAIL PHONE_NUMBER HIRE_DATE JOB_ID SALARY COMMISSION_PCT MANAGER_ID DEPARTMENT_ID DEPT_50_AVG_SAL ----------- -------------------- ------------------------- ------------------------- -------------------- --------- ---------- ---------- -------------- ---------- ------------- --------------- 194 Samuel McCain SMCCAIN 650.501.3876 01-JUL-06 SH_CLERK 3200 123 50 3475.55556 195 Vance Jones VJONES 650.501.4876 17-MAR-07 SH_CLERK 2800 123 50 3475.55556 196 Alana Walsh AWALSH 650.507.9811 24-APR-06 SH_CLERK 3100 124 50 3475.55556 197 Kevin Feeney KFEENEY 650.507.9822 23-MAY-06 SH_CLERK 3000 124 50 3475.55556 37 rows selected. SQL>
SY.
-
Hello
SQL query to find the total number of source based nonsource passangersbetween source and destination station and passenger station on the same chekindate.
Please help on this script and let me know if you need more details.
---
You use a SELECT statement. Let me know if you need more details.
-
What are these SQL statements?
Hello!
We are our applications running on Windows Server 2003 where it works fine, using Oracle via OCI 12.1.
Now, we have the application installed on Windows Server 2012 and it works very slowly.
When comparing these two environments trace files came a surprise: Oracle generates a lot of SQL statements when run on Windows Server 2012! By operating on Windows2003 it only executes the SQL from the applicaton instructions. These additional SQL statements must be the reason for the slowness, but why Oracle it generates them and how could we get arrested?
An example:
PARSING IN CURSOR #46985062096816 len = 210 dep = 2 uid = 0 oct = cover 3 = 0 tim = hv 1439277877325893 = ad 864012087 = "4db599f28" sqlid = "96g93hntrzjtr."
Select / * + rule * / bucket_cnt, row_cnt, cache_cnt, null_cnt, timestamp #, sample_size, minimum, maximum, distcnt, lowval, hival, density, col #, spare1, spare2, hist_head avgcln $ where obj #=: 1 and intcol #=: 2
END OF STMT
ANALYSIS #46985062096816:c = 1000, e = 456, p = 0, cr = 0, cu = 0, put = 1, r = 0, dep = 2, og = 3, plh = 0, tim = 1439277877325890
EXEC #46985062096816:c = 0, e = 498, p = 0, cr = 0, cu = 0, put = 1, r = 0, dep = 2, og = 3, plh = 2239883476, tim = 1439277877326455
FETCH #46985062096816:c = 0, e = 56, p = 0, cr = 3, cu = 0, set = 0, r = 1, dep = 2, og = 3, plh = 2239883476, tim = 1439277877326533
STAT #46985062096816 id = 1 cnt = 1 pid = 0 obj = op 411 = pos = 1 "TABLE ACCESS BY INDEX ROWID HIST_HEAD$ (cr = 3 pr = 0 pw = time 0 = 55 US)"
"STAT #46985062096816 id = 2 cnt = 1 pid = 1 pos = 1 obj = op 413 ='INDEX RANGE SCAN I_HH_OBJ #_INTCOL # (cr = 2 pr = 0 pw = time 0 = 32 US)"
OUTCOME #46985062096816:c = 0, e = 37, dep = 2, type = 3, tim = 1439277877326601
EXEC #46985062096816:c = 0, e = 23, p = 0, cr = 0, cu = 0, set = 0, r = 0, dep = 2, og = 3, plh = 2239883476, tim = 1439277877326702
FETCH #46985062096816:c = 0, e = 18, p = 0, cr = 3, cu = 0, set = 0, r = 1, dep = 2, og = 3, plh = 2239883476, tim = 1439277877326738
OUTCOME #46985062096816:c = 0, e = 8, dep = 2, type = 3, tim = 1439277877326765
EXEC #46985062096816:c = 0, e = 19, p = 0, cr = 0, cu = 0, set = 0, r = 0, dep = 2, og = 3, plh = 2239883476, tim = 1439277877326837
FETCH #46985062096816:c = 0, e = 21, p = 0, cr = 3, cu = 0, set = 0, r = 1, dep = 2, og = 3, plh = 2239883476, tim = 1439277877326923
OUTCOME #46985062096816:c = 0, e = 10, dep = 2, type = 3, tim = 1439277877326954
Thank you very much in advance!
Best regards
Jaakko Terhonen
Thank you all for the reply! This time, the reason was a problem in network traffic (TCP protocol): a lot of retransmissions for a still unknown reason. If it had nothing to do with Oracle after all.
I cried for help here because as a common application programmer, I wasn't familiar with the Interior details of SQL analysis and after seeing it in the trace, I assumed that these strange SQL statements - which, for some reason, is appeared only in W2012-trace - were the reason for the slowness.
Thank you, I'm a little wiser now - and I hope that many others find this thread before asking the same question!
Best regards
Jaakko Terhonen
-
Hi all
We have a problem with the profile option "initialize SQL statement - Custom." We put this at the user level. After awhile, we have erased the value of the this user profile option.
But you can still see the trace files generated are getting updated. We checked this files trc pathname returned at the bottom of the query.
Select name, value
the parameter $ v
WHERE name like 'user_dump_dest;
Please help us on how to solve this problem. We use Oracle Apps R 12.1.2 version.
Thanks in advance
Rambaud
Find the trace file creation session and kill this session
HTH
Srini -
Coil in SQL * Plus with SQL statements
Hi guru,.
Greetings.
I work 10 R2 Solaris oracle
I have the file new.sql having count (*) select statements of 10000 +. I want the result with the sql statement in the coil. How?
New.SQL
SELECT COUNT (*) IN XYZ. CPEP_ARTICLE;
SELECT COUNT (*) IN XYZ. CPEP_ARTICLE_GROUP;
SELECT COUNT (*) IN XYZ. CPEP_ARTICLE_GROUP_TR;
....
....
Coil new.txt
@new.sql
spool off
Spooled results is
SELECT COUNT (*) IN XYZ. CPEP_ARTICLE;
COUNT (*)
----------
199
SELECT COUNT (*) IN XYZ. CPEP_ARTICLE_GROUP;
COUNT (*)
----------
220
SELECT COUNT (*) IN XYZ. CPEP_ARTICLE_GROUP_TR;
COUNT (*)
----------
0
but I'm getting plain County, I need select statement and respective numeration.
How to get it. could you help on this.
Thank you
REDA
Like this.
Select "double ==>" | Count (*) twice;
-
any body can help me to merg below of the sql statements for the information
No. 1
Select S.USERNAME, s.sid, s.osuser, t.sql_id, sql_text
de v$ sqltext_with_newlines t, V$ SESSION s
où t.Address = s.sql_address
et t.hash_value = s.sql_hash_value
et s.status = 'ACTIVE'
et s.UserName <> 'SYSTEM'
order by s.sid, t.piece
/
Statements #2
SELECT SID, to_char (start_time,'hh24:mi:ss') stime,
message, (sofar/totalwork) * 100%
DE v$ session_longops
OÙ sofar/totalwork < 1
/
I tried
Select S.USERNAME, s.sid, s.osuser, t.sql_id, sql_text, to_char (sl.start_time,'hh24:mi:ss') stime,
- SL.message, (sl.sofar/sl.totalwork)* 100%
de v$ sqltext_with_newlines t, V$ SESSION s, v$ session_longops sl
where s.sid = sl.sid
and where t.Address = s.sql_address
et t.hash_value = s.sql_hash_value
et s.status = 'ACTIVE'
et s.UserName <> 'SYSTEM'
et OÙ sl.sofar/sl.totalwork < 1
order by s.sid, t.piece
but it gives me error.
SQL > select S.USERNAME, s.sid, s.osuser, t.sql_id, sql_text, to_char(sl.start_time,'hh24:mi:ss') stime,.
2 sl.message, (sl.sofar/sl.totalwork)* 100%
3 v $ sqltext_with_newlines t, V$ SESSION s, v$ session_longops sl
4 where s.sid = sl.sid
5 and where t.address = s.sql_address
and t.hash_value = s.sql_hash_value
6 and 7 s.status = 'ACTIVE '.
8 and s.username <>'SYSTEM '.
9 and WHERE the sl.sofar/sl.totalwork < 1
10 decree by s.sid, t.piece
11.
and where t.address = s.sql_address
*
ERROR on line 5:
ORA-00936: lack of expression
any body can help out?
Not tested, but you can try:
SELECT s.sid,
s.Serial #.
s.machine,
Round (SL.elapsed_seconds/60). ':' || MOD(SL.elapsed_seconds,60) has elapsed,
Round (SL.time_remaining/60). ':' || MOD(SL.time_remaining,60) remaining.
ROUND (sl.sofar/sl.totalwork*100, 2) progress_pct.
t.sql_id,
t.sql_text
V $ session s,.
v$ session_longops sl.
v$ sqltext_with_newlines t
WHERE s.sid = sl.sid
AND s.serial # sl.serial = #.
and t.address = s.sql_address
and t.hash_value = s.sql_hash_value
and s.status = 'ACTIVE '.
and s.username <> 'SYSTEM '.
order of s.sid, t.piece;
Or see if you can find a useful script here:
-
Sql statement variable gives several values
Hello
I have a variable that has sql statement and it gives several values and I want to use this variable in one of the filter of interface condition to filter the data in the source table (which has millions of records).
some could let me know the best method to achieve this scenario.
Appreciate your help.You are right. Yesterday, I don't think in this case where the data could be from a different server. But I completely forgot today.
Ok. Here you can find how to use sys_connect_by_pathhttp://asktom.Oracle.com/pls/asktom/f?p=100:11:0:P11_QUESTION_ID:907278700346567560
Be careful with the size because I think that there is a limit to what can contain the variable ODI.
After you have assessed the variable is how it could be used in the filter
ITEM_TYPE_ID IN (#var_csv_id_list)
-
"Balance forward" SQL statement
Anyone developing a SQL statement which helps to carry forward balances? A UNION query might work?
Here is my example where I need to join the 3 tables and display the results. According to data from the example below, I am looking for an application that allows me to illustrate that instances of Acrobat 9 software installed using 6 license capacity, or a balance of 4 which can be applied to Instances of installed software Acrobat 8.
Table: LICENSE
LICENSENUM SWLICENSE LICENSECAPACITY
'1001' "adobe Acrobat 9' 10'
Table: LICENSESW
PRIORITY SWPRODUCT LICENSENUM
"1001'"acrobat 9' 1".
"1001'"acrobat 8' 2".
Table: INSTALLEDSW
INSTALLEDSW
'Acrobat 9'
'Acrobat 9'
'Acrobat 9'
'Acrobat 9'
'Acrobat 9'
'Acrobat 9'
'Acrobat 8'
'Acrobat 8'
'Acrobat 8'
'Acrobat 8'
'Acrobat 8'
I can write a select for total of charges, but this does not allow me to carry a balance forward to be applied on Acrobat 8 (priority 2).
Select a LICENSE. SWLICENSE, LICENSE. LICENSECAPACITY County (INSTALLEDSW. INSTALLEDSW) as INSTALLED_COUNT
license, LICENSESW, INSTALLEDSW
where the LICENSE. LICENSENUM = LICENSESW. LICENSENUM
AND LICENSESW. SWPRODUCT = INSTALLEDSW. INSTALLEDSW
LICENSE group. SWLICENSE, LICENSE. LICENSECAPACITY;
Results:
SWLICENSE LICENSECAPACITY INSTALLED_COUNT
"Adobe Acrobat 9' 11 ' 10' '.
I need the results that look like this, where the balance of 4 is postponed after the first line:
SWLICENSE LICENSECAPACITY INSTALLED_PRODUCT INSTALLED_COUNT
"' Adobe Acrobat 9 6" "' Acrobat 6' 9" ""
«' Adobe Acrobat 4' 9 "' Acrobat 8 5'"»Not easy to follow your example data, but if I show which, in my opinion, you are trying to achieve using the emp table, you can see if it helps...
SQL> select deptno, empno, ename 2 ,count(*) over (partition by deptno) as dept_count 3 ,count(*) over (partition by deptno) - row_number() over (partition by deptno order by empno) as remaining 4 from emp 5 order by deptno, empno; DEPTNO EMPNO ENAME DEPT_COUNT REMAINING ---------- ---------- ---------- ---------- ---------- 10 7782 CLARK 3 2 10 7839 KING 3 1 10 7934 MILLER 3 0 20 7369 SMITH 5 4 20 7566 JONES 5 3 20 7788 SCOTT 5 2 20 7876 ADAMS 5 1 20 7902 FORD 5 0 30 7499 ALLEN 6 5 30 7521 WARD 6 4 30 7654 MARTIN 6 3 30 7698 BLAKE 6 2 30 7844 TURNER 6 1 30 7900 JAMES 6 0 14 rows selected.
by using the count() and row_number() analytical functions (you can use others such as sum(), avg(), lag(), lead(), etc. as needed), you can make treatment that carries forward, backward or "groups" (aka partitions) data.
Maybe you are looking for
-
Firefox 3.6.3 does not have the option 'Add exception' a self-signed certificate
Hello. Use the website of the company, I have moved to a new server. The new server needed some modifications apparently, and now I get the message CompanyXYZ .net: 987 uses an invalid security certificate. The certificate is not reliable because it
-
How to get rid of the blue screen... Yes I pressed the power button and the volume upward and down key but I still have a blue screen that says TPM (trusted platform module module) WARNING: Compensation erase the information stored on the TPM module.
-
R410 Sostituzione con PERC H700 hard drive
Supporto Gentile, If line a detailed by the sostituzione di un disco compatibile con quello hoist by R410 Server con controller perc h700 Speaking Saluti Gianluca Ticconi
-
adapters of current for the United Kingdom?
Hello, we have a new Dell with Windows Vista (Intel Core 2) desktop computer that we bought in the United States. We are moving to London at the end of this month and questioned current adapters to the United Kingdom? What will work for us here? A
-
1252 config several VLAN trunking on ethernet not
Hi all I am new to these forums, but have read some posts on configurations for an AP from 1252 to switch 2950. I have several VLANS andmultiple SSID configuration on my ap. The switch knows the VLANS on the access point I think that in the config.