SQL Group Query issue

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,
Sammy

Thanks 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

Similar Messages

  • Forms 6i Group Query Issue

    I am populating two Combo Box's by means of a group query. The end user has the option to clear this form by pressing a button which does a CLEAR_FORM built in function. Everything seems to clear fine except for Combo Box's. For some reason, they retain the returned group of records. I am sure I am missing something simple here but does anyone know the method to clear out the group list so that it no longer populates the Combo Box's. I have tried several things, i.e. setting the group to null, etc.
    Thanks
    BK

    Clearing the group does not affect the populated combo box. Instead, you can use CLEAR_LIST to clear all elements of the combo box.

  • 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}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

  • UCCX 5 SQL Dbase Query Issues - Slow Returns

    For several months it seemed to me that our UCCX 5 system was beginning to have trouble. At first it appeared as a problem with our wallboard system being unable to display the real-time data properly. I had deduced that queries to the db_cra database were taking 4 - 5 minutes to return data.
    At first I called on the vendor for our wallboard, but they were unable to help stating that it was a UCCX database issue - and I agreed. I then went to Cisco TAC and fed them all my information and asked them for help. They also were unable to help figure out what was happening, but they could see that the SQL queries that used to take 2 seconds were now taking several minutes. Since the wallboard system queried the database every 10 seconds, it was over-taxing the database.
    This began to cause little anomalies in things like call-distribution, dropped calls, slow to no Historical reports returns, and this ultimately began to cause failovers to our backup node. I could not go a day without a failover and I had to reboot the servers almost every night.
    I felt there was no solution and was afraid we needed to replace our system.
    After talking to all the engineers around the world, my solution came from our very own SQL administrator. Within 5 minutes he was able to resolve all our issues.
    The root of our problem was that the indexing of the db_cra database was extremely fragmented.
    He wrote a SQL sript that he had me run against the database and he told me that this would correct any indexing issues.
    It worked like a charm.
    The system stopped behaving poorly immediately. This resolved many of our problems that I had been living with for a long time. It made the Admin page work so much faster, call distribution issues halted, the wallboard is running faster than ever with real-time data, and the list goes on. This resolved so many smaller issues that I cannot even list them all.
    I would advise anyone using a SQL database, whether it be a Cisco product or not, to always keep their database 'defragmented'.
    My SQL admin also setup the script to run automatically, on a schedule to keep our database running like a Ferrari. It has been sweet ever since.
    KEEP YOUR INDEXES CLEAN AND YOU WILL REAP HAPPINESS!

    I was equally shocked that there was no escalation, as was my boss and my Cisco rep. They let me go with no resolution and hung-up the phone leaving me with instructions to have some-one else take a look at the database. It was very unexpected, especially considering how close they were to the point when we were trouble-shooting.
    The TAC SR # 611904619 - IPCC Database Not Returning Query Data.
    With this resolution, it also raised to my mind the issue of Informix. We are using CUCM 6.1.2 and are concerned about the same issue happening there and we would like to determine if this can happen there also, and if there is a re-indexing tool available for Informix.

  • PL/SQL region query issue

    Dears;
    I'm in trouble for a moment with my PL/sql block in a region.
    Could you take a look on the following block and tell me what i do wrong?
    DECLARE
    v_counter INTEGER := 0;
    v_line VARCHAR2 (4000);
    v_rec_in_row INTEGER := 12;
    lpar varchar2(50;
    BEGIN
    HTP.prn ('&lt table &gt ');
    HTP.prn ('&lt tr &gt ');
    HTP.prn ('&lt td &gt ');
    lpar:=v('P48_LVAR')
    CASE lpar
    WHEN 'SERVERS'
    THEN
                   FOR c IN
                        ( SELECT CASE
    WHEN SERVER_MARK='SUN'
    THEN '&lt table &gt '
    || '&lt tr &gt &lt td &gt &lt a href="#WORKSPACE_IMAGES#New Image.GIF" &gt &lt img src="#WORKSPACE_IMAGES#New Image.GIF"/ &gt &lt /td &gt &lt /tr &gt '
    || '&lt tr &gt &lt td style="text-align:center" &gt &lt h1 &gt '
    || SERVER_NAME
    || '&lt / &gt &lt /td &gt &lt /tr &gt &lt /a &gt &lt /table &gt '
    WHEN SERVER_MARK='HP'
    THEN '&lt table &gt '
    || '&lt tr &gt &lt td &gt &lt a href="#WORKSPACE_IMAGES#New Image.GIF" &gt &lt img src="#WORKSPACE_IMAGES#hp.GIF"/ &gt &lt /td &gt &lt /tr &gt '
    || '&lt tr &gt &lt td style="text-align:center" &gt &lt h1 &gt '
    || SERVER_NAME
    || '&lt / &gt &lt /td &gt &lt /tr &gt &lt /a &gt &lt /table &gt '
                                       END emp
                             FROM SERVERS)
                             LOOP
                             v_line := v_line || c.emp || '&lt /td &gt &lt td &gt ';
                             v_counter := v_counter + 1;
                             IF v_counter = v_rec_in_row
                             THEN
                                  HTP.prn (v_line);
                                  HTP.prn ('&lt /td &gt &lt /tr &gt &lt tr &gt &lt td &gt ');
                                  v_line := NULL;
                                  v_counter := 0;
                             END IF;
                        END LOOP;
                        HTP.prn (v_line);
                        HTP.prn ('&lt /td &gt &lt /tr &gt &lt /table &gt ');
    WHEN 'ZONES'
              THEN
                   FOR c IN
                        ( SELECT '&lt table &gt '
    || '&lt tr &gt &lt td &gt &lt a href="#WORKSPACE_IMAGES#New Image.GIF" &gt &lt img src="#WORKSPACE_IMAGES#New Image.GIF"/ &gt &lt /td &gt &lt /tr &gt '
    || '&lt tr &gt &lt td style="text-align:center" &gt &lt h1 &gt '
    || ZONE_NAME
    || '&lt / &gt &lt /td &gt &lt /tr &gt &lt /a &gt &lt /table &gt '
    END emp
                        FROM ZONES)
                        LOOP
                             v_line := v_line || c.emp || '&lt /td &gt &lt td &gt ';
                             v_counter := v_counter + 1;
                             IF v_counter = v_rec_in_row
                             THEN
                                  HTP.prn (v_line);
                                  HTP.prn ('&lt /td &gt &lt /tr &gt &lt tr &gt &lt td &gt ');
                                  v_line := NULL;
                                  v_counter := 0;
                             END IF;
                        END LOOP;
                        HTP.prn (v_line);
                        HTP.prn ('&lt /td &gt &lt /tr &gt &lt /table &gt ');
    WHEN 'ALIAS'
              THEN
                   FOR c IN
                        ( SELECT           
              '&lt table &gt '
    || '&lt tr &gt &lt td &gt &lt a href="#WORKSPACE_IMAGES#New Image.GIF" &gt &lt img src="#WORKSPACE_IMAGES#New Image.GIF"/ &gt &lt /td &gt &lt /tr &gt '
    || '&lt tr &gt &lt td style="text-align:center" &gt &lt h1 &gt '
    || ALIAS_NAME
    || '&lt / &gt &lt /td &gt &lt /tr &gt &lt /a &gt &lt /table &gt '
                                  END emp
                                  FROM ALIAS)
                                  LOOP
                                  v_line := v_line || c.emp || '&lt /td &gt &lt td &gt ';
                                  v_counter := v_counter + 1;
                                  IF v_counter = v_rec_in_row
                                  THEN
                                       HTP.prn (v_line);
                                       HTP.prn ('&lt /td &gt &lt /tr &gt &lt tr &gt &lt td &gt ');
                                       v_line := NULL;
                                       v_counter := 0;
                                  END IF;
                             END LOOP;
                             HTP.prn (v_line);
                             HTP.prn ('&lt /td &gt &lt /tr &gt &lt /table &gt ');
              WHEN 'FS'
              THEN
                   FOR c IN
                        ( SELECT
                        '&lt table &gt '
    || '&lt tr &gt &lt td &gt &lt a href="#WORKSPACE_IMAGES#New Image.GIF" &gt &lt img src="#WORKSPACE_IMAGES#New Image.GIF"/ &gt &lt /td &gt &lt /tr &gt '
    || '&lt tr &gt &lt td style="text-align:center" &gt &lt h1 &gt '
    || FS_NAME
    || '&lt / &gt &lt /td &gt &lt /tr &gt &lt /a &gt &lt /table &gt '
    END emp
    FROM FS
    LOOP
    v_line := v_line || c.emp || '&lt /td &gt &lt td &gt ';
    v_counter := v_counter + 1;
    IF v_counter = v_rec_in_row
    THEN
    HTP.prn (v_line);
    HTP.prn ('&lt /td &gt &lt /tr &gt &lt tr &gt &lt td &gt ');
    v_line := NULL;
    v_counter := 0;
    END IF;
    END LOOP;
    HTP.prn (v_line);
    HTP.prn ('&lt /td &gt &lt /tr &gt &lt /table &gt ');
    END CASE;
    END;
    I get this error :
    1 error has occurred
    ORA-06550: line 56, column 21: PL/SQL: ORA-00923: FROM keyword not found where expected ORA-06550: line 51, column 7: PL/SQL: SQL Statement ignored ORA-06550: line 83, column 13: PL/SQL: ORA-00923: FROM keyword not found where expected ORA-06550: line 77, column 7: PL/SQL: SQL Statement ignored ORA-06550: line 110, column 12: PL/SQL: ORA-00923: FROM keyword not found where expected ORA-06550: line 104, column 7: PL/SQL: SQL Statement ignored
    I know it's a long post but i hope u will take the time to look.
    Thx.
    Celio

    Okay, when using CASE you have to flavours.
    One for PL/SQL statements and one in a query.
    In PL/SQL the structure is like this:
    case n
      when 1 then Action1;
      when 2 then Action2;
      when 3 then Action3;
      else        ActionOther;
    end case;In a query it's like this:
    SELECT CASE WHEN (<column_value>= <value>) THEN
                WHEN (<column_value> = <value>) THEN
                ELSE <value>
                END AS <alias>
    FROM <table_name>;So rewriting your code, this should work:
    DECLARE
       v_counter     INTEGER         := 0;
       v_line        VARCHAR2 (4000);
       v_rec_in_row  INTEGER         := 12;
       lpar varchar2(50);
    BEGIN
       HTP.prn ('<table>');
       HTP.prn ('<tr>');
       HTP.prn ('<td>');
       lpar:=v('P48_LVAR');
       CASE
        WHEN lpar='SERVERS'
                    THEN 
                      FOR c IN
                          ( SELECT   CASE
                    WHEN SERVER_MARK='SUN'
                    THEN     '<table>'
                             || '<tr><td><a href="#WORKSPACE_IMAGES#New Image.GIF"><img src="#WORKSPACE_IMAGES#New Image.GIF"/></td></tr>'
                             || '<tr><td style="text-align:center"><h1>'
                             || SERVER_NAME
                             || '</td></tr></a></table>'
                    WHEN SERVER_MARK='HP'
                    THEN     '<table>'
                             || '<tr><td><a href="#WORKSPACE_IMAGES#New Image.GIF"><img src="#WORKSPACE_IMAGES#hp.GIF"/></td></tr>'
                             || '<tr><td style="text-align:center"><h1>'
                             || SERVER_NAME
                             || '</td></tr></a></table>'
                                       END AS emp
                              FROM SERVERS)
                              LOOP
                               v_line := v_line || c.emp || '</td><td>';
                               v_counter := v_counter + 1;
                               IF v_counter = v_rec_in_row
                               THEN
                                   HTP.prn (v_line);
                                   HTP.prn ('</td></tr><tr><td>');
                                   v_line := NULL;
                                   v_counter := 0;
                               END IF;
                           END LOOP;
                           HTP.prn (v_line);
                           HTP.prn ('</td></tr></table>');
       WHEN lpar='ZONES'
                THEN 
                      FOR c IN
                          ( SELECT '<table>'
                             || '<tr><td><a href="#WORKSPACE_IMAGES#New Image.GIF"><img src="#WORKSPACE_IMAGES#New Image.GIF"/></td></tr>'
                             || '<tr><td style="text-align:center"><h1>'
                             || ZONE_NAME
                             || '</td></tr></a></table>'
                     emp
                        FROM ZONES)
                        LOOP
                               v_line := v_line || c.emp || '</td><td>';
                               v_counter := v_counter + 1;
                               IF v_counter = v_rec_in_row
                               THEN
                                   HTP.prn (v_line);
                                   HTP.prn ('</td></tr><tr><td>');
                                   v_line := NULL;
                                   v_counter := 0;
                               END IF;
                           END LOOP;
                           HTP.prn (v_line);
                           HTP.prn ('</td></tr></table>');
       WHEN lpar='ALIAS'
                THEN 
                      FOR c IN
                          ( SELECT           
                               '<table>'
                             || '<tr><td><a href="#WORKSPACE_IMAGES#New Image.GIF"><img src="#WORKSPACE_IMAGES#New Image.GIF"/></td></tr>'
                             || '<tr><td style="text-align:center"><h1>'
                             || ALIAS_NAME
                             || '</td></tr></a></table>'
                                      emp
                                  FROM ALIAS)
                                  LOOP
                                    v_line := v_line || c.emp || '</td><td>';
                                    v_counter := v_counter + 1;
                                    IF v_counter = v_rec_in_row
                                    THEN
                                        HTP.prn (v_line);
                                        HTP.prn ('</td></tr><tr><td>');
                                        v_line := NULL;
                                        v_counter := 0;
                                    END IF;
                                END LOOP;
                                HTP.prn (v_line);
                                HTP.prn ('</td></tr></table>');
               WHEN lpar='FS'
                THEN 
                      FOR c IN
                          ( SELECT
                                  '<table>'
                             || '<tr><td><a href="#WORKSPACE_IMAGES#New Image.GIF"><img src="#WORKSPACE_IMAGES#New Image.GIF"/></td></tr>'
                             || '<tr><td style="text-align:center"><h1>'
                             || FS_NAME
                             || '</td></tr></a></table>'           
             emp
          FROM FS
       LOOP
          v_line := v_line || c.emp || '</td><td>';
          v_counter := v_counter + 1;
          IF v_counter = v_rec_in_row
          THEN
             HTP.prn (v_line);
             HTP.prn ('</td></tr><tr><td>');
             v_line := NULL;
             v_counter := 0;
          END IF;
       END LOOP;
       HTP.prn (v_line);
       HTP.prn ('</td></tr></table>');
    END CASE;
    END;Unless I'm missing something aswell ;-)
    Edited by: Michel van Zoest on Oct 6, 2009 10:46 PM

  • 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.

  • Sql select query problem

    hi friends,
    i've a view called "risk_efforts" with fields user_id,user_name,wknd_dt,week_day,prod_efforts,unprod_efforts.
    Name Type
    ROW_ID NUMBER
    USER_ID VARCHAR2(14)
    USER_NAME VARCHAR2(50)
    WKND_DT VARCHAR2(8)
    WEEK_DAY VARCHAR2(250)
    PROD_EFFORTS NUMBER
    UNPROD_EFFORTS NUMBER
    data is like this:
    when there is some data in prod_efforts, unprod_efforts will be null
    when there is some data in unprod_efforts, prod_efforts will be null
    for example:
    USER_ID     USER_NAME     WKND_DT     WEEK_DAY     PROD_EFFORTS     UNPROD_EFFORTS
    G666999     GTest     20100403     TUE     null 3
    G666999     GTest     20100403     TUE     14     null
    now i want to combine these 2 rows into 1 row i.e o/p should be like this
    USER_ID     USER_NAME     WKND_DT     WEEK_DAY     PROD_EFFORTS     UNPROD_EFFORTS
    G666999     GTest     20100403     TUE     14 3
    i've tried all combinations but couldn't get the query. Please help me with the exact SQL select query.
    thanks,
    Girish

    Welcome to the forum.
    First read this:
    Urgency in online postings
    Secondly, it's 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.
    You have provided #3 and #4. However with no usable form of sample data forum members will often not respond as quickly as they could if you provided #2.
    I'm just wagering a guess here but what about this:SELECT ROW_ID
    , USER_ID
    , WKND_DT
    , WEEK_DAY
    , MAX(PROD_EFFORTS) AS PROD_EFFORTS
    , MAX(UNPROD_EFFORTS) AS UNPROD_EFFORTS
    FROM RISK_EFFORTS
    GROUP BY ROW_ID
    , USER_ID
    , WKND_DT
    , WEEK_DAY                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           

  • Using SQL in Query in 3.0.0

    I'm very happy to see this feature added to 3.0.0 along with methodQL. This
    should alleviate a lot of the issues with trying to use only JDOQL,
    especially when the desired SQL statemetn is well understood. Thanks for
    adding this!
    Ben

    Marc,
    Calling pm.flush() explicitly doesn't help. Calling
    query.setIgnoreCache(true) does work, so that's good.
    I even get the correct number of rows back in the Collection. Unfortunately
    every item in the Collection is null. I definitely did a
    query.setClass(DSChannelValueImpl.class) and it is enhanced properly,
    because that's how the table got populated earlier in the test. I am doing a
    SELECT *, so the class indicator and pk should be there. I'm assuming it
    doesn't mind me aliasing the FROM table name, since I need to disambiguate
    it to do a join (below).
    Ben
    "Marc Prud'hommeaux" <[email protected]> wrote in message
    news:[email protected]...
    Ben-
    I've made a bug report for this:
    http://bugzilla.solarmetric.com/show_bug.cgi?id=780
    In the meantime, a nicer workaround will probably be to just call
    setIgnoreCache(true) on the Query.
    In article <[email protected]>, Marc Prud'hommeaux wrote:
    Ben-
    A potential (but, admittedly, not very nice) workaround for this for the
    time being might be to enable NonTransactionalRead=true, and ensure that
    there is not a transaction running at the time of query execution.
    In article <[email protected]>, Patrick Linskey wrote:
    Well, sounds like a bug. We'll take a look. Sorry about that.
    What happens if you explicitly flush the PM before execution?
    -Patrick
    Ben Eng wrote:
    Query query = pm.newQuery( "kodo.jdbc.SQL", null );
    query.setClass( ChannelValue.class );
    query.declareParameters( "VARCHAR pConn, DATETIME pStart,
    DATETIME pEnd" );
    String filter = "select * from dschannel as c" +
    " left join channelsegment as s" +
    " on c.pk = s.channel and" +
    " c.supporting = pConn and" +
    " (s.validForEnd > pStart or" +
    " s.validForStart < pEnd)" +
    " where s.channel is null";
    query.setFilter( filter );
    Collection resultSet = (Collection) this.query.execute(
    connection, start, end );
    This is being called from a method of a stateless session bean that is
    only
    performing this query. CMT, Required, and the client is not definingits own
    transaction boundaries. Therefore, I would not expect anything to bedirtied
    in this transaction. This is with the BEA WLS 7.0 appserver.
    Ben
    "Patrick Linskey" <[email protected]> wrote in message
    news:[email protected]...
    Ben,
    Can you post the code that you're using to create the query?
    -Patrick
    Ben Eng wrote:
    I just ran into a snag with this feature.
    kodo.util.UnsupportedOptionException: kodo.jdbc.SQL language queries
    cannot
    be executed in-memory. Either set the javax.jdo.option.IgnoreCacheproperty
    to true, set the kodo.FlushBeforeQueries property to true, or executethe
    query before modifying objects within the transaction.
    at
    kodo.jdbc.query.SQLQuery.newInMemoryQueryExecutor(SQLQuery.java:117)
    at kodo.query.AbstractQuery.internalCompile(AbstractQuery.java:545)
    atkodo.query.AbstractQuery.getAccessPathMetaDatas(AbstractQuery.java:938)
    >>>>
    atkodo.query.AbstractQuery.isAccessPathDirty(AbstractQuery.java:745)
    at kodo.query.AbstractQuery.executeWithMap(AbstractQuery.java:672)
    at kodo.query.AbstractQuery.executeWithArray(AbstractQuery.java:640)
    at kodo.query.AbstractQuery.execute(AbstractQuery.java:622)
    at
    com.metasolv.resources.queries.ChannelAvailabilityQueryBean.execute(ChannelA
    >>>>
    vailabilityQueryBean.java:84)
    at
    com.metasolv.oss.inventory.InventorySessionBean.queryInventory(InventorySess
    >>>>
    ionBean.java:1504)
    Oddly, my ra.xml already has the following properties set.
    <config-property>
    <description>If false, then the JDO implementation mustconsider
    modifications, deletions, and additions in the PersistenceManager
    transaction cache when executing a query inside a transaction. Else,the
    implementation is free to ignore the cache and execute the querydirectly
    against the data store.</description>
    <config-property-name>IgnoreCache</config-property-name>
    <config-property-type>java.lang.Boolean</config-property-type>
    <config-property-value>true</config-property-value>
    </config-property>
    <config-property>
    <description>Whether or not Kodo should automatically flush
    modifications to the data store before executingqueries.</description>
    >>>>>>
    <config-property-name>FlushBeforeQueries</config-property-name>
    <config-property-type>java.lang.String</config-property-type>
    <config-property-value>true</config-property-value>
    </config-property>
    I also tried explicitly calling ((KodoPersistenceManager)pm).flush()before
    newQuery to no avail. I am at a loss how to get the Query to NOT
    execute
    in-memory.
    Ben
    "Ben Eng" <[email protected]> wrote in message
    news:[email protected]...
    I'm very happy to see this feature added to 3.0.0 along with
    methodQL.
    >>>>>>
    This
    should alleviate a lot of the issues with trying to use only JDOQL,
    especially when the desired SQL statemetn is well understood. Thanks
    for
    adding this!--
    Marc Prud'hommeaux [email protected]
    SolarMetric Inc. http://www.solarmetric.com

  • Official documents on escaping characters in SQL Server query statements

    Hi,
    Are there any official documents on how to escaping special characters in SQL Server query statements? I find a lot of online resources discussing about this, but there are no definitive conclusions on:
    Which characters should be escaped? (Some only said single-quote needs to be escaped, double-quote does not need. While others said both need to be escaped)
    How to escape characters? (Some said using two single-quote to escape a single-quote. Others said using a backslash, etc.)
    So I just wonder if there is an official document from Microsoft regarding this?
    Thanks
    Alan

    Depends on where you're using them
    If its string values then single quotes(') should be escaped by putting one more single quote before it.
    If its LIKE operator you can use ESCAPE keyword or use [] to escapre special characters 
    see
    http://visakhm.blogspot.in/2013/01/wildcard-character-based-pattern-search.html
    If inside SSIS expression you can escape characters like \ " etc by adding an extra \ before the characters
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • 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

  • List item - Record Group Query - Alignment improper Order

    Dear All,
    When am trying to concatenate two columns using record group query and displaying in the list item, the alignment is not in proper order.
    E.g; Below is the columns and data's used in process:
    CODE_VALUE     SHORT_DESC     DESCRIPTION
    ROLL1     Customer - Non accidental     Production, booking with other carrier, bad projection.
    ROLL2     Customer - Accidental     L/C, B/L draft, Customs, Samples, AMS, LAR.
    ROLL3     ABC - Lack of empty     Lack of empty units.
    ROLL4     ABC CDE - Roll over     AGR RRR decision.
    ROLL5     ABC XXX - Accidental     IMO or OOG refused, operational problems, Cut & Run.
    ROLL6     ABC YYY - Fictive booking     Equipment buffer, dummy booking.
    Below is the record group query used in forms:
    PROCEDURE p_when_new_form_instance
    IS
    GROUP_ID recordgroup;
    list_id item := FIND_ITEM ('BLK_CONTROL.LI_ROLL_REASON');
    rg_name VARCHAR2 (20) := 'LI_ROLL_REASONS';
    status NUMBER;
    l_query VARCHAR2 (4000);
    BEGIN
    l_query :=
    'SELECT rpad(short_desc,50,'' '')||'' | ''||description description, code_value code_value FROM codes WHERE code_value IN (''ROLL1'', ''ROLL2'', ''ROLL3'',''ROLL4'',''ROLL5'',''ROLL6'')';
    GROUP_ID := CREATE_GROUP_FROM_QUERY (rg_name, l_query);
    status := POPULATE_GROUP (GROUP_ID);
    POPULATE_LIST (list_id, GROUP_ID);
    EXCEPTION
    WHEN OTHERS
    THEN
    pl_common.when_others;
    END;
    Moreover i have my list item font property by default as ""MS SANS SERIF" and when i run in Forms Builder am getting the alignment as below.
    Result:
    ====
    DESCRIPTION     CODE_VALUE
    Customer - Non accidental | Production, booking with other carrier, bad projection.     ROLL1
    Customer - Accidental | L/C, B/L draft, Customs, Samples, AMS, LAR.     ROLL2
    ABC - Lack of empty | Lack of empty units.     ROLL3
    ABC CDE - Roll over | AGR RRR decision.     ROLL4
    ABC XXX - Accidental | IMO or OOG refused, operational problems, Cut & Run.     ROLL5
    ABC YYY - Fictive booking | Equipment buffer, dummy booking.      ROLL6
    Above order is not the expected result as all the |(pipe) symbol should display in proper order as below.
    Expected Result:
    ==========
    DESCRIPTION     CODE_VALUE
    Customer - Non accidental | Production, booking with other carrier, bad projection.     ROLL1
    Customer - Accidental | L/C, B/L draft, Customs, Samples, AMS, LAR.     ROLL2
    ABC - Lack of empty | Lack of empty units.     ROLL3
    ABC CDE - Roll over | AGR RRR decision.     ROLL4
    ABC XXX - Accidental | IMO or OOG refused, operational problems, Cut & Run.     ROLL5
    ABC YYY - Fictive booking | Equipment buffer, dummy booking.      ROLL6
    I tried with RPAD and LPAD still the alignment issue is there; i know the issue is because of invariable length of the font.
    But is there any solution to override this it will be of great help.
    So please help!!!!!!!!!!!!!!!!!
    Thanks..................
    Regards,
    Sunil.G

    Hi Francois,
    Thanks for your reply. I have tried changing the font to "Courier(Western)" it is working fine.
    But as per the standards defined, it should be "Ms Sans Serif" nothing apart from that.So that is where the problem lies. :(
    Regards,
    Sunil.G

  • ORA-00904 when use column alias in Record Group Query

    Is it possible to use column aliases in Record Group Queries?
    I have a query that runs fine in SQL*Developer, but gives me runtime errors when I use it as a Record Group Query.
    When I use it as a Record Group Query, the Form compiles, but at runtime I receive the following errors:
    FRM-40502: ORACLE error: unable to read list of values
    when I use Help - Display Error, I see:
    ORA-00904:"CHILDNAME":invalid identifier
    The query is something like this
    select decode(complex stuff here) as "childname" ....
    I've tried it with and without the double quotes surrounding the alias name, and have also tried it without using the "as" keyword.
    I would appreciate any suggestions or insights. I'm using Forms 9.0.4.
    Thanks.

    It looks like this is caused by bug 725059:
    "FILTER BEFORE DISPLAY" DOESN'T WORK IF LOV HAS COLUMN ALIASES (TRIAGE1098)
    My LOV does have the Filter Before Display turned on. Here's the text of the bug:
    IF an LOV is created with column aliases in the select statement, (eg: select ename emp_name from emp) and the LOV property "Filter Before Display" is "Yes", THEN when you attempt to filter the LOV at runtime, (eg: type '%' then press the 'Find' button) the internal WHERE clause that forms sends to the database is: WHERE column_alias LIKE '%%' This is incorrect syntax. A client-side sqlnet trace shows this. The correct syntax should be: WHERE column LIKE '%%' . The incorrect syntax results in no rows returned. However no error is displayed by forms to the user.

  • SQL Azure - query with row_number() executes slow if columns with nvarchar of big size are included

    I am linking my question from Stack Overflow here. The link: http://stackoverflow.com/questions/27943913/sql-azure-query-with-row-number-executes-slow-if-columns-with-nvarchar-of-bi
    Appreciate your help!
    Gorgi

    Hi,
    Thanks for posting here.
    I suggest you to check this link and optimize your query on sql azure.
    http://www.sqlusa.com/articles/query-optimization/
    http://sqlblog.com/blogs/paul_white/archive/2011/02/23/Advanced-TSQL-Tuning-Why-Internals-Knowledge-Matters.aspx
    Also check this blog which had similar issue.
    https://social.msdn.microsoft.com/Forums/en-US/c1da08b4-265d-4ec8-a252-8d7090234e3e/simple-select-query-takes-long-time-to-execute-with-nvarchar-columns?forum=transactsql
    Girish Prajwal

  • SQL Server Connection Issue

    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.

  • LDAP group query failure during per-recipient scanning, poss

    I am trying to figure out what this is referring to:
    LDAP group query failure during per-recipient scanning, possible LDAP misconfiguration or unreachable server
    I can still send test messages from my e-mail.
    Is it possible tht a user is trying to send in corectly..hmmm

    If you create a LDAP debug log from within the GUI, this will give you a more in depth look into the query that is being sent to your LDAP server and also more important any errors that are being returned.
    Great log for troubleshooting any LDAP related issues.

Maybe you are looking for

  • Text in Dreamweaver?

    I'm taking over a simple website from someone who was using DreamWeaver. I see that any large blocks of text on the website are images. I was told that this is because there was a "kerning"(?) problem when they went to type text directly into a layer

  • Repair permissions in Disk Utility won't stop

    OK, I've never done permissions repair on our MacBook Pro 15" (2 GB 1067 MHz DDR3, 2.4 GHz Intel Core 2 Duo).  (My apologies to the fastidious cleaners among this group.)  I've done multiple upgrades over the past 4 or so years that we've owned it, i

  • Itunes wont install on vistax64

    i tryed to upgrade it but that failed so i tryed to uninstall and then try to reinstall but no it has an error and wont install at all i need help its says the installer encountered errors before itunes could be configured. your system has been modif

  • Galleries Tell a friend

    When using Galleries Tell a Friend feature, Is there any way to change who the email is from? When the email arrives from .Mac Web Galleries, My family and friends email app. sorts it out as junk mail. And or they delete it as if it were spam. Thanks

  • HT203687 I have exchange server 64bit contacts google Ipad Iphone and a PC at home32bit how on earth do you get them to work together wthout duplicattng everythng?

    It would seem that someone or Isomethng is working against me. I cannt sync at the offce t want just use my google contacts and I cloud does not let you set anyhing. Just make it work. If Itunes had a contacts manager in it all would be well in Iworl