*Silly* SQL Question - SQL Newbie

Hello,
Thanks for taking the time reading this.
Im a SQL Newbie
Question?
I Have a PHONE_TABLE, which consist of
a BUREAU Column and a STATUS Column.
Within the STATUS column exist 'active' and 'inactive'
I would like to know if it's possible to create a report that groups a Bureau and counts the # of active /inactive phones
that displays
\BUREAU/- - -\Active/ - - - -\Inactive/
- - - - HR - - - - - 3 - - - - - - - --4 - - - - - - - -
- - - - IT - - - - - 1 -- - - - -- - - 5 - - - - - - - - -
- - MGMT - -- -- 3 - - - - -- - - 6 - - - - -- -
Thanks for the help guys

Try this:
select bureau, sum(decode(status,'Active',1,0) ) active , sum (decode(status,'Inactive',1,0) )  inactive
from PHONE_TABLE
group by bureauHope this helps!
Sam
Please reward good answers by marking them correct or helpful!

Similar Messages

  • SQL Question Bank and Answers for Practise

    Dear Readers:
    Does any one have any recommendation on SQL question bank and answers where I could practice my SQL.
    I have developed some basic knowledge of SQL thanks to the MS community, but I am looking for some additional Questions or textbook  recommendations which has questions and answers to queries for practice.
    Best Wishes,
    SQL75

    Hi,
    Refer below post.
    https://social.msdn.microsoft.com/Forums/sqlserver/en-US/446b2247-5124-49c1-90c9-b7fea0aa4f83/sql-dba-books?forum=sqlgetstarted
    Please mark solved if I've answered your question, vote for it as helpful to help other users find a solution quicker
    Praveen Dsa | MCITP - Database Administrator 2008 |
    My Blog | My Page

  • Sql question : TRUNCATE vs Delete

    hi
    this is sql question, i don't know where i should post it, so here it is.
    i just want to know the best usage of each. both commands delete records in a table, one deletes all, and the other can do the same plus option to delete specified records. if i just want to purge the table. which one is better and why? thanks

    this is crucial to my design, i need to be able to
    rollback if one of the process in the transaction
    failed, the whole transaction should rollback. if
    truncate does not give me this capability, then i have
    to consider Delete.From the Oracle manual (sans the pretty formatting):
    TRUNCATE
    Caution: You cannot roll back a TRUNCATE statement.
    Purpose
    Use the TRUNCATE statement to remove all rows from a table or cluster. By default,
    Oracle also deallocates all space used by the removed rows except that specified by
    the MINEXTENTS storage parameter and sets the NEXT storage parameter to the size
    of the last extent removed from the segment by the truncation process.
    Removing rows with the TRUNCATE statement can be more efficient than dropping
    and re-creating a table. Dropping and re-creating a table invalidates the table?s
    dependent objects, requires you to regrant object privileges on the table, and
    requires you to re-create the table?s indexes, integrity constraints, and triggers and
    respecify its storage parameters. Truncating has none of these effects.
    See Also:
    DELETE on page 16-55 and DROP TABLE on page 17-6 for
    information on other ways to drop table data from the database
    DROP CLUSTER on page 16-67 for information on dropping
    cluster tables
    Prerequisites
    To truncate a table or cluster, the table or cluster must be in your schema or you
    must have DROP ANY TABLE system privilege.

  • Urgent SQL question : how to flip vertical row values to horizontal ?

    Hello, Oracle people !
    I have an urgent SQL question : (simple for you)
    using SELECT statement, how to convert vertical row values to horizontal ?
    For example :
    (Given result-set)
    MANAGER COLUMN1 COLUMN2 COLUMN3
    K. Smith ......1
    K. Smith ...............1
    K. Smith ........................1
    (Needed result-set)
    MANAGER COLUMN1 COLUMN2 COLUMN3
    K. Smith ......1 .......1 .......1
    I know you can, just don't remeber how and can't find exactly answer I'm looking for. Probably using some analytic SQL function (CAST OVER, PARTITION BY, etc.)
    Please Help !!!
    Thanx !
    Steve.

    scott@ORA92> column vice_president format a30
    scott@ORA92> SELECT f.VICE_PRESIDENT, A.DAYS_5, B.DAYS_10, C.DAYS_20, D.DAYS_30, E.DAYS_40
      2  FROM   (select t2.*,
      3                row_number () over
      4                  (partition by vice_president
      5                   order by days_5, days_10, days_20, days_30, days_40) rn
      6            from   t2) f,
      7           (SELECT T2.*,
      8                row_number () over (partition by vice_president order by days_5) RN
      9            FROM   T2 WHERE DAYS_5 IS NOT NULL) A,
    10           (SELECT T2.*,
    11                row_number () over (partition by vice_president order by days_10) RN
    12            FROM   T2 WHERE DAYS_10 IS NOT NULL) B,
    13           (SELECT T2.*,
    14                row_number () over (partition by vice_president order by days_20) RN
    15            FROM   T2 WHERE DAYS_20 IS NOT NULL) C,
    16           (SELECT T2.*,
    17                row_number () over (partition by vice_president order by days_30) RN
    18            FROM   T2 WHERE DAYS_30 IS NOT NULL) D,
    19           (SELECT T2.*,
    20                row_number () over (partition by vice_president order by days_40) RN
    21            FROM   T2 WHERE DAYS_40 IS NOT NULL) E
    22  WHERE  f.VICE_PRESIDENT = A.VICE_PRESIDENT (+)
    23  AND    f.VICE_PRESIDENT = B.VICE_PRESIDENT (+)
    24  AND    f.VICE_PRESIDENT = C.VICE_PRESIDENT (+)
    25  AND    f.VICE_PRESIDENT = D.VICE_PRESIDENT (+)
    26  AND    f.VICE_PRESIDENT = E.VICE_PRESIDENT (+)
    27  AND    f.RN = A.RN (+)
    28  AND    f.RN = B.RN (+)
    29  AND    f.RN = C.RN (+)
    30  AND    f.RN = D.RN (+)
    31  AND    f.RN = E.RN (+)
    32  and    (a.days_5 is not null
    33            or b.days_10 is not null
    34            or c.days_20 is not null
    35            or d.days_30 is not null
    36            or e.days_40 is not null)
    37  /
    VICE_PRESIDENT                     DAYS_5    DAYS_10    DAYS_20    DAYS_30    DAYS_40
    Fedele Mark                                                          35473      35209
    Fedele Mark                                                          35479      35258
    Schultz Christine                              35700
    South John                                                                      35253
    Stack Kevin                                    35701      35604      35402      35115
    Stack Kevin                                    35705      35635      35415      35156
    Stack Kevin                                    35706      35642      35472      35295
    Stack Kevin                                    35707      35666      35477
    Stack Kevin                                               35667      35480
    Stack Kevin                                               35686
    Unknown                             35817      35698      35596      35363      35006
    Unknown                                        35702      35597      35365      35149
    Unknown                                        35724      35599      35370      35155
    Unknown                                                   35600      35413      35344
    Unknown                                                   35601      35451      35345
    Unknown                                                   35602      35467
    Unknown                                                   35603      35468
    Unknown                                                   35607      35475
    Unknown                                                   35643      35508
    Unknown                                                   35644
    Unknown                                                   35669
    Unknown                                                   35684
    Walmsley Brian                                 35725      35598
    23 rows selected.

  • Easy-ish sql question

    sorry guys, wasnt sure where else to put this so hope it is ok to post it here. I currently have a field in my database which stores date and time however i am writting an sql statemenet and need to only use the date of the datetime, what would be the correct syntext to do sowould i have to use to_char etc?
    Thank you.

    Are you doing something specific to Oracle Forms? If not, you may want to consider posting your question in the SQL - PL/SQL forum (url below). If this is Forms specific, please indicate exactly which Forms version you are using. The database version you plan to use may also be helpful as there may be a variety of ways of accomplishing your goal depending on the versions.
    PL/SQL

  • Servlet + JSP + SQL question

    I have a servlet that is executing a few queries against a database. I am fowarding the results to a jsp page to display the results. I have been able to do this. My problem is when my query selects more than one field I am unsure on how to read that into an array or something like that. All the results I have done so far have had multiple results but only from one field in the database. Here is my serlvet and jsp code. If some one could tell me how to read multiple field into an array and display them on a jsp page that would be great. Thank you
    Servlet
    package nnet;
    import javax.servlet.*;
    import javax.servlet.http.*;
    import java.io.*;
    import java.util.*;
    import java.security.Principal;
    import java.sql.*;
    import java.sql.DriverManager;
    * <p>Title: NNET</p>
    * <p>Description: Northland Intranet</p>
    * <p>Copyright: Copyright (c) 2004</p>
    * <p>Company: NMI</p>
    * @author not attributable
    * @version 1.0
    public final class home
    extends HttpServlet {
    //Initialize global variables
    //Initialize queries
    private static final String USERQUERY =
    "SELECT public.tblindividual.firstname as firstname " +
    "FROM public.tblloginname " +
    "INNER JOIN public.tblindividual ON (public.tblloginname.indlink = public.tblindividual.indid) " +
    "WHERE LOWER(public.tblloginname.loginname) = LOWER(?)";
    private static final String MAINLINKQUERY =
    "SELECT public.nnetsection.name " +
    "FROM public.nnetsection " +
    "WHERE public.nnetsection.posted = 'true'";
    private static final String ANOUNCEMENTQUERY =
    "SELECT public.nnetanouncement.anouncement, to_char(nnetanouncement.postdate,'MonthDD, YY') as postdate " +
    "FROM public.nnetanouncement " +
    "ORDER BY public.nnetanouncement.postdate DESC";
    public void init() throws ServletException {
    //Process the HTTP Get request
    public void doGet(HttpServletRequest request, HttpServletResponse response) throws
    ServletException, IOException {
    Connection con = null;
    PreparedStatement stmt = null;
    //Initialize Resultset objects
    ResultSet namers = null;
    ResultSet mainlinkrs = null;
    ResultSet anouncementrs = null;
    ResultSet anouncementdaters = null;
    //Initialize Array Lists
    ArrayList mainlinkresults = new ArrayList();
    ArrayList anouncementresults = new ArrayList();
    String firstnameresult = null;
    Principal user = request.getUserPrincipal();
    String username = user.getName();
    Properties props = new Properties();
    InputStream in = getServletContext().getResourceAsStream(
    "/WEB-INF/sql.properties");
    props.load(in);
    in.close();
    //get Users login name to pass on
    try {
    Class.forName(props.getProperty("connection.driver"));
    con = DriverManager.getConnection(props.getProperty("connection.url"), props);
    stmt = con.prepareStatement(USERQUERY);
    stmt.setString(1, username);
    namers = stmt.executeQuery();
    while (namers.next()) {
    firstnameresult = namers.getString("firstname");
    //results.add(namers.getString("firstname"))
    catch (SQLException ex1) {
    catch (ClassNotFoundException ex) {
    finally {
    if (stmt != null) {
    try {
    stmt.close();
    catch (SQLException e) {
    e.printStackTrace();
    stmt = null;
    if (con != null) {
    try {
    con.close();
    catch (SQLException e) {
    e.printStackTrace();
    con = null;
    //get the main links to pass on
    try {
    Class.forName(props.getProperty("connection.driver"));
    con = DriverManager.getConnection(props.getProperty("connection.url"), props);
    stmt = con.prepareStatement(MAINLINKQUERY);
    mainlinkrs = stmt.executeQuery();
    while (mainlinkrs.next()) {
    mainlinkresults.add(mainlinkrs.getString("name"))
    catch (SQLException ex1) {
    catch (ClassNotFoundException ex) {
    finally {
    if (stmt != null) {
    try {
    stmt.close();
    catch (SQLException e) {
    e.printStackTrace();
    stmt = null;
    if (con != null) {
    try {
    con.close();
    catch (SQLException e) {
    e.printStackTrace();
    con = null;
    //get the announcements to pass on
    try {
    Class.forName(props.getProperty("connection.driver"));
    con = DriverManager.getConnection(props.getProperty("connection.url"), props);
    stmt = con.prepareStatement(ANOUNCEMENTQUERY);
    anouncementrs = stmt.executeQuery();
    while (anouncementrs.next()) {
    anouncementresults.add(anouncementrs.getString("anouncement"));
    catch (SQLException ex1) {
    catch (ClassNotFoundException ex) {
    finally {
    if (stmt != null) {
    try {
    stmt.close();
    catch (SQLException e) {
    e.printStackTrace();
    stmt = null;
    if (con != null) {
    try {
    con.close();
    catch (SQLException e) {
    e.printStackTrace();
    con = null;
    request.setAttribute("firstname", firstnameresult);
    request.setAttribute("mainlink", mainlinkresults);
    request.setAttribute("anouncement", anouncementresults);
    RequestDispatcher rd =
    request.getRequestDispatcher("home.jsp");
    rd.forward(request, response);
    //Clean up resources
    public void destroy() {
    JSP Page
    <%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
    <%@ taglib uri="http://java.sun.com/jstl/sql" prefix="sql" %>
    <%@ taglib uri="http://java.sun.com/jstl/xml" prefix="x" %>
    <html>
    <head>
    <title>
    index
    </title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"><style type="text/css">
    <!--
    body {
         margin-left: 0px;
         margin-top: 0px;
         margin-right: 0px;
         margin-bottom: 0px;
    -->
    </style></head>
    <body bgcolor="#008000">
    <table width="100%" border="1" cellspacing="0" bordercolor="#000000">
    <tr>
    <td bgcolor="#FFFFFF"><h1>Welcome to NNET <c:out value="${requestScope.firstname}" /></h1>
    </td>
    </tr>
    </table>
    <br>
    <table width="100%" border="0" cellspacing="0">
    <tr>
    <td width="150"><table width="100%" border="1" cellspacing="0" bordercolor="#000000" bgcolor="#FFFFFF">
    <tr>
    <td><strong>Main Links </strong></td>
    </tr>
    <c:forEach var="item" items="${requestScope.mainlink}">
    <tr>
    <td valign="top"><c:out value="${item}"/></td>
    </tr>
    </c:forEach>
    </table>
    <p> </p></td>
    <td><table width="100%" border="0" cellspacing="0" bgcolor="#FFFFFF">
    <tr>
    <td valign="top"><h2>Announcements</h2>
    <p>
    <c:forEach var="item" items="${requestScope.anouncement}">
    <c:out value="${item}" />
    </c:forEach>
    </p>
    </td>
    </tr>
    </table></td>
    <td width="150"> </td>
    </tr>
    </table>
    </body>
    </html>

    OK if you look at the code I pasted above I have doen that. I hav ethat book and it is good. My question is how do I get the data read into a multidemisional array or an arraylist like I am using in the code above so I can access that on the jsp page. Can you give an example. Here is what I want . I have a table called anouncements with 3 fields (ID, name, url) I am returning say 10 results. I want to store them in a single arraylist or multideminsional array and call them on the jsp page. What syntax would I use on the servlet and on the jsp page for this? I know how to do it as seen above when I return only one field with many results from the database. Thank you in advance for any help

  • XML parsing with SQL/PL-SQL

    Hi,
    My question is about how can an XML message can be best parsed using SQL/PL-SQL.
    The scenario is as follow. The XML message is stored in a CLOB; only some of its data needs to be extracted; there are six different types of structures of XML; the size of each XML is about 50 lines (maximum depth level is 3); the data could be written in English or Greek or French or German or Russian; this is going to be done every hour and the parsing is going to be against 3,000 records approx.
    In the development, I need to take into consideration performance. We are using Oracle 10, but we could migrate to Oracle 11 if necessary.
    Apologies for this basic question but I have never done XML parsing in SQL/PL-SQL before.
    Thank you.
    PS I have copied this question to the XML forum.
    Edited by: user3112983 on May 19, 2010 3:30 PM
    Edited by: user3112983 on May 19, 2010 3:39 PM

    user3112983 wrote:
    The scenario is as follow. The XML message is stored in a CLOB; only some of its data needs to be extracted; there are six different types of structures of XML; the size of each XML is about 50 lines (maximum depth level is 3); the data could be written in English or Greek or French or German or Russian; this is going to be done every hour and the parsing is going to be against 3,000 records approx.Parsing is done using the XMLTYPE data type (object class) in Oracle.
    Something as follows:
    SQL> create table xml_doc( id number, doc clob );
    Table created.
    SQL>
    SQL> insert into xml_doc values( 1, '<root><row><name>John</name></row><row><name>Jack</name></row></root>' );
    1 row created.
    SQL> commit;
    Commit complete.
    SQL>
    SQL> declare
      2          rawXml  xml_doc.doc%type;
      3          xml     xmltype;
      4  begin
      5          -- get the raw XML (as a CLOB)
      6          select doc into rawXml from xml_doc where id = 1;
      7
      8          -- parse it
      9          xml := new xmltype( rawXml );  
    10         -- process the XML...
    11  end;
    12  /
    PL/SQL procedure successfully completed.
    SQL>The variable xml in the sample code is the XML DOM object. XML functions can be used against it (e.g. to extract values in a tabular row and column structure).
    Note that the CLOB needs to contain a valid XML. An XML containing XML fragments is not valid and cannot be parsed. E.g.
    SQL> declare
      2          xml     xmltype;
      3  begin
      4          -- attemp to parse fragments
      5          xml := new xmltype( '<row><name>John</name></row>  <data><column>Name</column></data>' );
      6  end;
      7  /
    declare
    ERROR at line 1:
    ORA-31011: XML parsing failed
    ORA-19202: Error occurred in XML processing
    LPX-00245: extra data after end of document
    Error at line 1
    ORA-06512: at "SYS.XMLTYPE", line 301
    ORA-06512: at line 5This XML contains 2 fragments. A row structure and a data structure. It is not a valid XML and as such cannot be parsed. If a root tag is used to encapsulate these 2 fragments, then it will be a valid XML structure.
    In the development, I need to take into consideration performance. We are using Oracle 10, but we could migrate to Oracle 11 if necessary.Have not run into any XML performance problems specifically - and am using it extensively. Even large XMLs (10's of 1000's of elements) parse pretty fast.

  • SQL Fundamentals I : oe_main.sql , hr_main.sql, ...

    Hi forum,
    I just bought "SQL Fundamentals I" from McGraw Hill. This book mentions several schemas and creation scripts like hr_main.sql,
    oe_main.sql, ... ! Unfortunately I cannot find these scripts for download and it is not on the accompanying CD. In the meantime
    I sestablished a 10G Express Database on my notebook for training purposes. The hr schema and the tables in question could
    be found there. Does anyone know where to find the scripts necessary for studying this book ?
    Kind regards
    oeggert2706

    user11128142 wrote:
    Hi forum,
    I just bought "SQL Fundamentals I" from McGraw Hill. This book mentions several schemas and creation scripts like hr_main.sql,
    oe_main.sql, ... ! Unfortunately I cannot find these scripts for download and it is not on the accompanying CD. In the meantime
    I sestablished a 10G Express Database on my notebook for training purposes. The hr schema and the tables in question could
    be found there. Does anyone know where to find the scripts necessary for studying this book ?
    Kind regards
    oeggert2706HR and OE etc. are standard schemas that come as part of the Database installation. Not sure about the express edition, but as Oracle provide them as example schemas, I don't see why they wouldn't be included with that version.
    http://download.oracle.com/docs/cd/B12037_01/server.101/b10771/scripts003.htm
    http://download.oracle.com/docs/cd/B13789_01/server.101/b10771/installation002.htm

  • MS SQL Error SQL 137

    Hi,
    i encounter MS SQL Error SQL 137, what is this error ? and how to resolve this? Thanks
    halim

    Your question has nothing to do with this forum or indeed this website. Locked.

  • Problem opening an Excel rowset in SQL/T-SQL

    
    In SSMS ((SS 2008 R2) when I run:
    SELECT * FROM
    OPENROWSET (
    'Microsoft.ACE.OLEDB.12.0',
    'Excel 12.0;Database=C:\test\xltest.xls;HDR=YES;IMEX=1',
    'SELECT * FROM [Sheet1$]'
    From this article:
    http://social.msdn.microsoft.com/Forums/sqlserver/en-US/3ffcbe7c-cdce-43cd-97b1-ea480bbbfff9/openrowset-excel
    I get error:
    Msg 7403, Level 16, State 1, Line 1
    The OLE DB provider "Microsoft.ACE.OLEDB.12.0" has not been registered.
    However, over in SSIS, the Excel Connection Manager connection string property (which works!) is:
    Provider=Microsoft.ACE.OLEDB.12.0;Data Source= C:\test\xltest.xls;Extended Properties="EXCEL 12.0 XML;HDR=NO";
    Showing that Microsoft.ACE.OLEDB.12.0 is registered on this machine.
    What do I need to do in SQL/T-SQL to have the code work?

    Those issues are a challenge to fix: search web, install, new error, search web, install, new error.....
    I found it easier to use the SSIS Import/Export Wizard:
    http://www.sqlusa.com/bestpractices/ssis-wizard/
    It is a charm!
    Kalman Toth Database & OLAP Architect
    SELECT Video Tutorials 4 Hours
    New Book / Kindle: Exam 70-461 Bootcamp: Querying Microsoft SQL Server 2012
    Kalman,  
    This would be great content for a Wiki article:
    http://social.technet.microsoft.com/wiki/contents/articles/23330.technet-guru-contributions-for-march.aspx#SQL_BI_amp_Power_BI
    Thanks!
    Ed Price, Power BI & SQL Server Customer Program Manager (Blog,
    Small Basic,
    Wiki Ninjas,
    Wiki)
    Answer an interesting question?
    Create a wiki article about it!

  • PL/SQL vs SQL

    What are the fundamental differences between PL/SQL and SQL?

    Just to expand on what was said.
    PL/SQL is a formal procedural language based on Ada (Ada and Pascal are very similar). PL/SQL is in that respect equivalent to C, Pascal, Visual Basic etc.
    What makes PL/SQL different (a 4GL instead of a 3GL) is that it is specifically designed to deal with data processing problems in Oracle using SQL.
    In 3GLs you need to use SQL pre-compilers or special classes (wrapping the database's SQL call interface) to talk SQL to the database. E.g. Pro*C precompiler for use with C. The TQuery class in Delphi that wraps the Oracle Call Interface (OCI) into an object class.
    PL/SQL goes further as it allows you to natively use SQL inside the language, as if it is part of the language. The PL compiler/PL engine is however clever enough to recognise SQL statements and do the complex stuff needed to make a SQL call to the SQL engine. It handles bind variables for you. It handles SQL data types for you. It does the SQL engine call for you. It fetches the data from the SQL engine for you. Etc.
    Using SQL natively in the PL language is what makes PL/SQL so powerfull. It blurs the line between having to deal with two separate langauges - a procedure (and object orientated) programming language and the SQL language.
    This blurring does have its cons . Developers often fail to recognise just what is PL and what is SQL ito doing a proper program design and implementation. Or they treat PL/SQL as something different than Java, Delphi or C/C++. A programming language is a programming language, Programming 101 fundamentals apply. Irrespective of the language. Period.
    For example, they use PL/SQL cursor fetch loops to process SQL data in a row-by-row fashion, instead of using SQL to do that work instead. SQL is by far superior in this regard. Or they use SQL (i.e. SELECT func() INTO var FROM dual) to assign values from functions to PL/SQL variables. Why use SQL to do perform this variable assignment when dealing with PL variables?
    There are numerous brain farts from developers in this respect. Not understanding PL/SQL. Not even bothering to familiarise themselves with the Oracle manuals on the language. Which is a pity as this result in crappy code and a developer that fails to understand Oracle. Worse, developers start to dislike Oracle because it "does not work properly" due to their utter failure to grasp the concepts of the database and the language.
    However, if you understand what PL is and what SQL is in PL/SQL, and you treat both languages correctly, no other language on this planet allows you to process Oracle data more effectively. Fact: PL/SQL scales and performs better than whatever Java architecture and code you can deploy on an application tier.

  • How to resolve most of the Oracle SQL , PL/SQL Performance issues with help of quick Checklist/guidelines ?

    Please go thru below important checklist/guidelines to identify issue in any Perforamnce issue and resolution in no time.
    Checklist for Quick Performance  problem Resolution
    ·         get trace, code and other information for given PE case
              - Latest Code from Production env
              - Trace (sql queries, statistics, row source operations with row count, explain plan, all wait events)
              - Program parameters & their frequently used values
              - Run Frequency of the program
              - existing Run-time/response time in Production
              - Business Purpose
    ·         Identify most time consuming SQL taking more than 60 % of program time using Trace & Code analysis
    ·         Check all mandatory parameters/bind variables are directly mapped to index columns of large transaction tables without any functions
    ·         Identify most time consuming operation(s) using Row Source Operation section
    ·         Study program parameter input directly mapped to SQL
    ·         Identify all Input bind parameters being used to SQL
    ·         Is SQL query returning large records for given inputs
    ·         what are the large tables and their respective columns being used to mapped with input parameters
    ·         which operation is scanning highest number of records in Row Source operation/Explain Plan
    ·         Is Oracle Cost Based Optimizer using right Driving table for given SQL ?
    ·         Check the time consuming index on large table and measure Index Selectivity
    ·         Study Where clause for input parameters mapped to tables and their columns to find the correct/optimal usage of index
    ·         Is correct index being used for all large tables?
    ·         Is there any Full Table Scan on Large tables ?
    ·         Is there any unwanted Table being used in SQL ?
    ·         Evaluate Join condition on Large tables and their columns
    ·         Is FTS on large table b'cos of usage of non index columns
    ·         Is there any implicit or explicit conversion causing index not getting used ?
    ·         Statistics of all large tables are upto date ?
    Quick Resolution tips
    1) Use Bulk Processing feature BULK COLLECT with LIMIT and FOR ALL for DML instead of row by row processing
    2) Use Data Caching Technique/Options to cache static data
    3) Use Pipe Line Table Functions whenever possible
    4) Use Global Temporary Table, Materialized view to process complex records
    5) Try avoiding multiple network trips for every row between two database using dblink, Use Global temporary table or set operator to reduce network trip
    6) Use EXTERNAL Table to build interface rather then creating custom table and program to Load and validate the data
    7) Understand Oracle's Cost based Optimizer and Tune most expensive SQL queries with help of Explain plan
    8) Follow Oracle PL/SQL Best Practices
    9) Review tables and their indexes being used in the SQL queries and avoid unnecessary Table scanning
    10) Avoid costly Full Table Scan on Big Transaction tables with Huge data volume,
    11) Use appropriate filtration condition on index columns of seeded Oracle tables directly mapped to program parameters
    12) Review Join condition on existing query explain plan
    13) Use Oracle hint to guide Oracle Cost based optimizer to choose best plan for your custom queries
    14) Avoid applying SQL functions on index columns
    15) Use appropriate hint to guide Oracle CBO to choose best plan to reduce response time
    Thanks
    Praful

    I understand you were trying to post something helpful to people, but sorry, this list is appalling.
    1) Use Bulk Processing feature BULK COLLECT with LIMIT and FOR ALL for DML instead of row by row processing
    No, use pure SQL.
    2) Use Data Caching Technique/Options to cache static data
    No, use pure SQL, and the database and operating system will handle caching.
    3) Use Pipe Line Table Functions whenever possible
    No, use pure SQL
    4) Use Global Temporary Table, Materialized view to process complex records
    No, use pure SQL
    5) Try avoiding multiple network trips for every row between two database using dblink, Use Global temporary table or set operator to reduce network trip
    No, use pure SQL
    6) Use EXTERNAL Table to build interface rather then creating custom table and program to Load and validate the data
    Makes no sense.
    7) Understand Oracle's Cost based Optimizer and Tune most expensive SQL queries with help of Explain plan
    What about using the execution trace?
    8) Follow Oracle PL/SQL Best Practices
    Which are?
    9) Review tables and their indexes being used in the SQL queries and avoid unnecessary Table scanning
    You mean design your database and queries properly?  And table scanning is not always bad.
    10) Avoid costly Full Table Scan on Big Transaction tables with Huge data volume,
    It depends if that is necessary or not.
    11) Use appropriate filtration condition on index columns of seeded Oracle tables directly mapped to program parameters
    No, consider that too many indexes can have an impact on overall performance and can prevent the CBO from picking the best plan.  There's far more to creating indexes than just picking every column that people are likely to search on; you have to consider the cardinality and selectivity of data, as well as the volumes of data being searched and the most common search requirements.
    12) Review Join condition on existing query explain plan
    Well, if you don't have your join conditions right then your query won't work, so that's obvious.
    13) Use Oracle hint to guide Oracle Cost based optimizer to choose best plan for your custom queries
    No.  Oracle recommends you do not use hints for query optimization (it says so in the documentation).  Only certain hints such as APPEND etc. which are more related to certain operations such as inserting data etc. are acceptable in general.  Oracle recommends you use the query optimization tools to help optimize your queries rather than use hints.
    14) Avoid applying SQL functions on index columns
    Why?  If there's a need for a function based index, then it should be used.
    15) Use appropriate hint to guide Oracle CBO to choose best plan to reduce response time
    See 13.
    In short, there are no silver bullets for dealing with performance.  Each situation is different and needs to be evaluated on its own merits.

  • SQL to SQL Append

    Hi,
    I have a interface to load data from tables to table into same Oracle server, the target table is truncate every time that run interface and the data is just insert (don't update), i read that can use "IKM SQL to SQL Append" to avoid extra loading phases ( like flow tables, create index, etc. ). I put source table and datastore table from the same model, select "Staging Area Diferent from Target" and select the apropiate staging. The problem is that i can select the "IKM SQL to SQL Append" in the flow tab.
    Please can you help me with that ? i need this option to improve performance and space, every time that this interfaces run load aprox. 3 million of registers about 9 times with diferent conditions.
    Thanks.
    Juan Carlos Lopez
    Startegic Account Sales Consultant
    Oracle Venezuela

    Hola Juan, que tal estas?
    Eso es muy sencillo....
    Just import (or use if it is already imported) the KM Control Append and change the option "Flow Control" to No.
    Plus, let the Staging Area together at Target.
    I believe that will solve your problem because will generate just one step to load the data...
    If you have big problems on this, is very simple to change a KM....
    Un Saludo!
    Cezar Santos

  • Dilemma of an OCA (SQL, PL/SQL) with 4 years work-ex

    Dear all,
    I am an OCA(SQL, PL/SQL) and working on a enhancement/production support project (Tech: JAVA and Oracle, Func: Insurance) in my firm. I am doing quite well here and keep updating myself using oracle documentation and application functionality. But in a long term, I am confused about my career path, what should I do next? Should I upgrade myself with certification in advanced PL/SQL or should I move towards DBA activities or should I learn JAVA to be an software architect?
    Personally, I have great interest in oracle database, design and implementation, what can be a career path for a software architect?
    Please help.

    OracleDeft wrote:
    Dear all,
    I am an OCA(SQL, PL/SQL) and working on a enhancement/production support project (Tech: JAVA and Oracle, Func: Insurance) in my firm. I am doing quite well here and keep updating myself using oracle documentation and application functionality. But in a long term, I am confused about my career path, what should I do next? Should I upgrade myself with certification in advanced PL/SQL or should I move towards DBA activities or should I learn JAVA to be an software architect?
    Personally, I have great interest in oracle database, design and implementation, what can be a career path for a software architect?
    Please help.Bringing you PL/SQL up to OCP by studying for and taking 1z0-146 is probably a straightford and low impact descision.
    It may not however be in the route you wish to take your career, but it is relatively low cost and good gain.
    My impression is your not currently into Java ... learning that from the bottom may be a hard process and even having learn Java than in itself does not make one a software architect.
    Take a browse down all Oracle Certifications at [http://www.oracle.com/education/certification] ... certifications ... view all certifications ... but remember not all Oracle products / technologies have associated certifications.
    Consider SOA or BIEE or Oracle Application Express as well
    -

  • Convert Oracle SQL line to SQL Server SQL

    Hi All,
    I'm trying to convert this Oracle SQL to SQL that will work with SQL Server 2008 and am having some trouble with the MOD function. Anyone have any SQL Server chops?
    Oracle SQL
    TBL_MAIN.AuthoredDate- MOD (TBL_MAIN.AuthoredDate - to_date ('2012-01-01', 'fxYYYY-MM-DD'), 7) + 6 AS "Week Ending"
    SQL Server Code
    TBL_MAIN.AuthoredDate - ((Cast(TBL_MAIN.AuthoredDate as DATE) % CAST('2012-01-01' AS DATE)), 7) + 6 AS "Week Ending" Thanks,
    John
    Edited by: Johnbr (Oracle10G) on Mar 1, 2013 8:41 AM

    ahhh.. I just had to change my thinking... I got it now:
    SQL Server SQL
    DATEADD(dd, 7-(DATEPART(dw, TBL_MAIN.AuthoredDate)), TBL_MAIN.AuthoredDate) AS 'Week Ending'

Maybe you are looking for

  • MacBook Pro 17" airport help (noob)

    I have had a consistant problem with my new macbook. It could be a simple problem that I haven't noticed. I have a 8Mbps connection via a wireless router (linksys). I have gotten a very slow initial connection. I can download files very very fast lik

  • Just updated iphone 4 and now no tv shows are syncing

    I updated my iphone and now no tv shows are showing on the iphone. They are showing in itunes, but here is the weird part, when Sync TV shows is DE-SELECTED it shows a certain amount of blue for audio, purple for video, same for photos, apps and othe

  • JMS consumer is not receiving any messages. am i missing something ?

    Hi bellow is the consumer code, my consumer is not receiving any messages even though there are messages in the queue. I have tried to debug the code. but the consumer is not calling the onMessage() method even though there are messages in the queue.

  • Flex 2 14 backlit keyboard replacement.

    Hello, i just bought a flex 2 14 model: 20404. all models of flex 2 does not come with a backlit keyboard in our country, my question is: can I replace my keyboard with a backlit and were can i buy or order it?

  • From iBook to MacBook, from '06 to '08: A big leap indeed!

    I currently have an iBook. I have just purchased a new MacBook. I created a site using iWeb '06, and I need to: (1) transfer the website from iBook to MacBook (2) and go from '06 to '08. How does one transfer a site from one computer to another? (Eve