Can this query work?

I'm having trouble with a query because I need the Count results in the query below to refer only to the current column of the SQL Report:
select T1.id,
T1.name,
(select count(*) from T1 where typeid = 222
AND id = # T1.id#) "COUNT 1",
(select count(*) from T1 where typeid = 262
AND id = # T1.id#) "COUNT 2"
from T1
order by T1.name
Is this possible to do? If I substitute an actual ID instead of the #T1.id#, it returns the results that I want.
Thanks much,
Nora

Try this -
select
  a.id,
  a.name,
  (select count(*) from t1 b where b.typeid = 222 and b.id = a.id) 'COUNT 1',
  (select count(*) from t1 b where b.typeid = 262 and b.id = a.id) 'COUNT 2',
from
  t1 a
order by a.nameWithout more details about what you're trying to achieve it's hard to suggest (better) alternatives

Similar Messages

  • How can this query avoid full table scans?

    It is difficult to avoid full table scans in the following query because the values of column STATUS reiterant numbers. There are only 10 numbers values for the STATUS column (1..10)
    But the table is very large. there are more than 1 million rows in it. A full table scanning consumes too much time.
    How can this query avoid full table scans?
    Thank you
    SELECT SYNC,CUS_ID INTO V_SYNC,V_CUS_ID FROM CONSUMER_MSG_IDX
                      WHERE CUS_ID = V_TYPE_CUS_HEADER.CUS_ID AND
                            ADDRESS_ID = V_TYPE_CUS_HEADER.ADDRESS_ID AND
                            STATUS =! 8;Edited by: junez on Jul 23, 2009 7:30 PM

    Your code had an extra AND. I also replaced the "not equal" operator, which has display problems with the forum software
    SELECT SYNC,CUS_ID
       INTO V_SYNC,V_CUS_ID
      FROM CONSUMER_MSG_IDX
    WHERE CUS_ID = V_TYPE_CUS_HEADER.CUS_ID AND
           ADDRESS_ID = V_TYPE_CUS_HEADER.ADDRESS_ID AND
           STATUS != 8;Are you sure this query is doing a table scan? Is there an index on CUS_ID, ADDRESS_ID? I would think that would be mostly unique. So I'm not sure why you think the STATUS column is causing problems. It would seem to just be a non-selective additional filter.
    Justin

  • Can this HSRP work?

    Hi,
    Can this scenario work?
    Assuming I have a flat network, a computer with 2 NICs and are connected to 2 different routers. I configure the routers to run HSRP between them. But the routers do not have any layer 2 or layer 3 interconnects between each other.
    Can HSRP work this way?

    Leo is correct in that HSRP won't actually be working do to the fact that it can't exchange hellos. Both routers will think that they are the primary.
    If your looking at trying to get a redundant setup here is how you would have to set your equipment up. Router A would be connected to switch A which would be connected to switch B which would be connected to RTR B. Your computer with the two nics would then have one connected to switch A and one connected to Switch B
    Patrick

  • Can this query be optimised?

    Hi,
    This query is taking more time to execute. please can someone advise..
    SELECT reference_value AS billing_system_account_id,
    account_id AS sim_account_id
    FROM account_reference
    WHERE reference_name = 'ACCOUNT_ID'
    AND account_id IN
    (SELECT DISTINCT (ACCOUNT_ID)
    FROM asset
    WHERE status NOT IN ('CEASED', 'CANCELLED')
    AND asset_id IN
    (SELECT asset_id
    FROM asset_config
    WHERE config_name IN
    ('userName', 'login')
    AND (config_value IN
    ('abc'
    || '@abc',
    'abc'))))

    Using EXISTS instead of IN, as Salim suggested, might work for you.
    Some more explanation:
    http://asktom.oracle.com/pls/asktom/f?p=100:11:2095243262787694::::P11_QUESTION_ID:953229842074
    But anyway:
    when posting a tuning request, you always need to mention:
    - your database version
    - an execution plan of the query (or tkprof output)
    - information regarding indexes
    - information regarding table statistics
    in order to make it possible for us to help you better.
    Please read these informative threads regarding posting tuning requests:
    When your query takes too long ...
    HOW TO: Post a SQL statement tuning request - template posting

  • How does this query work?

      UPDATE medfileinfo mf
          SET total_tap_count = total_tap_count-
                                   (SELECT   COUNT (1)
                                        FROM rating_temp rt
                                       WHERE ( ( ( (calledcallzone IS NULL) OR (callingcallzone IS NULL))  AND calltype = 0)   OR (charges_inr IS NULL))
                                       AND rt.fileid=mf.fileid
        WHERE EXISTS (SELECT   COUNT (1)
                                        FROM rating_temp rt
                                        WHERE ( ( ( (calledcallzone IS NULL) OR (callingcallzone IS NULL))  AND calltype = 0)   OR (charges_inr IS NULL))
                                       AND rt.fileid=mf.fileid)
          AND chargedamount=0;

    After the question has solved on HOW this works. I guess you have a issue with this? Performance?
    This query will tell you what it will do:
    SELECT mf.fileid,mf.total_tap_count,rt.cnt,
    mf.total_tap_count-rt.cnt new_total_tap_count
    FROM
         medfileinfo mf 
        INNER JOIN (SELECT fileid,count(*) cnt FROM rating_temp
                            WHERE  ( ( ( (calledcallzone IS NULL) OR (callingcallzone IS NULL))  AND calltype = 0)   OR (charges_inr IS NULL))
                                GROUP BY fileid ) rt
         ON rt.fileid=mf.fileid)
    WHERE chargedamount=0;And if you want to get rid of subselects use MERGE like this:
    MERGE medfileinfo target
    USING
    (SELECT mf.fileid,mf.total_tap_count,rt.cnt,
    mf.total_tap_count-rt.cnt new_total_tap_count
    FROM
         medfileinfo mf 
        INNER JOIN (SELECT fileid,count(*) cnt FROM rating_temp
                            WHERE  ( ( ( (calledcallzone IS NULL) OR (callingcallzone IS NULL))  AND calltype = 0)   OR (charges_inr IS NULL))
                                GROUP BY fileid ) rt
         ON rt.fileid=mf.fileid) source
    ON (target.fileid = source.fileid
       and target.chargedamount=0)
      WHEN MATCHED THEN UPDATE
         SET total_tap_count = source.new_total_tap_count;

  • Why is this query working??

    According to the rules of GROUP BY statement, this query shoun't work
    SELECT e.secction_id,
    COUNT(*) AS num,
    (SELECT s.capacity FROM section S WHERE E.section_id=S.section_id ) capacity
    FROM enrollment e
    GROUP BY e.section_id
    The column capacity is obtained from a correlated subquery, it is not a group function. I made this query , it gives correct results, but after a while i recognized that it doesn't follow the rules of group by statements.
    Thanks in advance.
    Edited by: chg78 on 16-mar-2011 2:11
    Edited by: chg78 on 16-mar-2011 2:11

    chg78 wrote:
    SELECT e.secction_id,
    COUNT(*) AS num,
    (SELECT s.capacity FROM section S WHERE E.section_id=S.section_id ) capacity
    FROM enrollment e
    GROUP BY e.section_idThe column capacity is obtained from a correlated subquery, it is not a group function. I made this query , it gives correct results, but after a while i recognized that it doesn't follow the rules of group by statements.The query fetching collumn capacity is executed for each row of the outer query. So this is a ugly but valid statement.
    bye
    TPD

  • Can this phone work in Egypt???

    The Phone Link??
    http://www.bestbuy.com/site/Boost+Mobile+-+Samsung​+Galaxy+S+II+4G+No-Contract+Mobile+Phone+-+White/6​...
    i wonder if it can work on vodafone or mobinil or any network in Egypt??
    Thank u in advance

    You'd have to cross reference the frequency bands with the carriers you mentioned. You can also contact them directly to verify if this phone works with their network.
    Thanks!
    Jesus|Senior Social Media Specialist | Best Buy® Corporate
     Private Message

  • HT5246 Everyone has Java installed - how can this tool work?

    Every Mac (and PC user for that matter) has Java installed.  Even if you did not have it, Apple's last two updates installed new versions.  How can this malware tool work?  And why is it limited to Lion? 
    Apple - this is not what your customers rightly expect and could be crippling to your reputation.
    Do this over and do it right.  Thankyou.

    Every Mac (and PC user for that matter) has Java installed.
    That's incorrect.
    How can this malware tool work?
    By updating Java, if present, and removing the malware files, if present.
    And why is it limited to Lion?
    It isn't. There's a Java update for Mac OS X 10.6.8 that does the same things.

  • Can this Query be written better?

    Dear Experts,
    I have this SQL running long, can this be re-written to improve performance. Below is the SQL stmt and its current execution plan:
    /* Formatted on 9/12/2012 3:04:16 PM (QP5 v5.163.1008.3004) */
    SELECT *
      FROM       SEA_DWSTG.XO_E_PER_ASSIGNMENT_P XO_E_PER_ASSIGNMENT_P
              RIGHT OUTER JOIN
                 SEA_DWSTG.X_SNI_FUEL_PUR_TXN_P X_SNI_FUEL_PUR_TXN_P
              ON X_SNI_FUEL_PUR_TXN_P.DRV_NUM = XO_E_PER_ASSIGNMENT_P.DRV_NUM
                 AND X_SNI_FUEL_PUR_TXN_P.TXN_DTTM BETWEEN XO_E_PER_ASSIGNMENT_P.ASN_EFF_STRT_DT
                                                       AND XO_E_PER_ASSIGNMENT_P.ASN_EFF_END_DT
                 AND XO_E_PER_ASSIGNMENT_P.PS_CURR_IND = 1
                 AND XO_E_PER_ASSIGNMENT_P.DRV_NUM IS NOT NULL
                 AND XO_E_PER_ASSIGNMENT_P.ACTV_EMP_IND = 1
                 AND XO_E_PER_ASSIGNMENT_P.PRSN_TYP_RNK_NUM = 1
           LEFT OUTER JOIN
                    SEA_DWSTG.X_SNI_FUEL_PLN_STP_DTL_P X_SNI_FUEL_PLN_STP_DTL_P
                 RIGHT OUTER JOIN
                    SEA_DWSTG.X_SNI_FUEL_CMPLY_DTL_P X_SNI_FUEL_CMPLY_DTL_P
                 ON (X_SNI_FUEL_PLN_STP_DTL_P.PWR_NUM =
                        X_SNI_FUEL_CMPLY_DTL_P.PWR_NUM)
                    AND X_SNI_FUEL_PLN_STP_DTL_P.PLN_DTTM =
                           X_SNI_FUEL_CMPLY_DTL_P.PLN_DT
                    AND (X_SNI_FUEL_PLN_STP_DTL_P.pln_stp_dtl_id,
                         X_SNI_FUEL_PLN_STP_DTL_P.pwr_num,
                         X_SNI_FUEL_PLN_STP_DTL_P.pln_gal_qty) IN
                           (SELECT pln_stp_dtl_id, pwr_num, pln_gal_qty
                              FROM (SELECT pln_stp_dtl_id,
                                           pwr_num,
                                           pln_gal_qty,
                                           pln_dttm,
                                           ROW_NUMBER ()
                                           OVER (PARTITION BY pwr_num, pln_dttm
                                                 ORDER BY pln_stp_dtl_id DESC)
                                              r1
                                      FROM SEA_DWSTG.X_SNI_FUEL_PLN_STP_DTL_P)
                             WHERE r1 = 1)
              LEFT OUTER JOIN
                 SEA_DWSTG.X_SNI_TRK_STP_P X_SNI_TRK_STP_P
              ON X_SNI_FUEL_PLN_STP_DTL_P.PRVD_TRK_STP_CD =
                    X_SNI_TRK_STP_P.CMDTA_CD
           ON X_SNI_FUEL_PUR_TXN_P.FUEL_PUR_TXN_ID =
                 X_SNI_FUEL_CMPLY_DTL_P.FUEL_PUR_TXN_ID,
           SEA_DWSTG.X_SNI_FUEL_PUR_TXN_PRD_P X_SNI_FUEL_PUR_TXN_PRD_P
    WHERE (1 = 1)
           AND (X_SNI_FUEL_PUR_TXN_PRD_P.FUEL_PUR_TXN_ID =
                   X_SNI_FUEL_PUR_TXN_P.FUEL_PUR_TXN_ID
                AND X_SNI_FUEL_PUR_TXN_PRD_P.PS_CURR_IND = 1
                AND X_SNI_FUEL_PUR_TXN_P.PS_CURR_IND = 1)
    PLAN_TABLE_OUTPUT
    Plan hash value: 2124177374
    | Id  | Operation                         | Name                     | Rows  | Bytes |TempSpc| Cost (%CPU)| Time     |
    |   0 | SELECT STATEMENT                  |                          |  5909K|    24G|       |    26M  (2)| 98:57:55 |
    |*  1 |  HASH JOIN RIGHT OUTER            |                          |  5909K|    24G|   446M|    26M  (2)| 98:57:55 |
    |   2 |   VIEW                            |                          |   690K|   438M|       |    25M  (2)| 96:08:32 |
    |*  3 |    HASH JOIN OUTER                |                          |   932K|   586M|   232M|    25M  (2)| 96:09:23 |
    |   4 |     VIEW                          |                          |   458K|   226M|       |    25M  (2)| 96:08:32 |
    |   5 |      NESTED LOOPS OUTER           |                          |   458K|   162M|       |    25M  (2)| 96:08:32 |
    |   6 |       TABLE ACCESS FULL           | X_SNI_FUEL_CMPLY_DTL_P   | 30548 |  3430K|       |    46   (3)| 00:00:01 |
    |   7 |       VIEW                        |                          |    15 |  3855 |       |   845   (2)| 00:00:12 |
    |*  8 |        FILTER                     |                          |       |       |       |            |          |
    |*  9 |         HASH JOIN SEMI            |                          |    15 |  1995 |       |   845   (2)| 00:00:12 |
    |* 10 |          TABLE ACCESS FULL        | X_SNI_FUEL_PLN_STP_DTL_P |    15 |  1425 |       |   150   (2)| 00:00:03 |
    |  11 |          VIEW                     | VW_NSO_1                 |   151K|  5639K|       |   694   (2)| 00:00:10 |
    |* 12 |           VIEW                    |                          |   151K|  7569K|       |   694   (2)| 00:00:10 |
    |* 13 |            WINDOW SORT PUSHED RANK|                          |   151K|  3413K|  5376K|   694   (2)| 00:00:10 |
    |  14 |             TABLE ACCESS FULL     | X_SNI_FUEL_PLN_STP_DTL_P |   151K|  3413K|       |   150   (2)| 00:00:03 |
    |  15 |     TABLE ACCESS FULL             | X_SNI_TRK_STP_P          |  5609 |   772K|       |    10   (0)| 00:00:01 |
    |* 16 |   HASH JOIN                       |                          |  5909K|    20G|    89M|   409K  (1)| 01:31:27 |
    |* 17 |    TABLE ACCESS FULL              | X_SNI_FUEL_PUR_TXN_PRD_P |  1032K|    77M|       |  1011   (4)| 00:00:14 |
    |  18 |    VIEW                           |                          |  6959K|    23G|       | 13071   (2)| 00:02:56 |
    |* 19 |     HASH JOIN OUTER               |                          |  6959K|  5322M|   179M| 13071   (2)| 00:02:56 |
    |* 20 |      TABLE ACCESS FULL            | X_SNI_FUEL_PUR_TXN_P     |  1019K|   168M|       |  2087   (3)| 00:00:28 |
    |* 21 |      TABLE ACCESS FULL            | XO_E_PER_ASSIGNMENT_P    |   297K|   178M|       |  5061   (2)| 00:01:08 |
    Predicate Information (identified by operation id):
       1 - access("X_SNI_FUEL_PUR_TXN_P"."FUEL_PUR_TXN_ID"="X_SNI_FUEL_CMPLY_DTL_P"."FUEL_PUR_TXN_ID"(+))
       3 - access("X_SNI_FUEL_PLN_STP_DTL_P"."PRVD_TRK_STP_CD"="X_SNI_TRK_STP_P"."CMDTA_CD"(+))
       8 - filter("X_SNI_FUEL_CMPLY_DTL_P"."PLN_DT" IS NOT NULL)
       9 - access("X_SNI_FUEL_PLN_STP_DTL_P"."PLN_STP_DTL_ID"="PLN_STP_DTL_ID" AND
                  "X_SNI_FUEL_PLN_STP_DTL_P"."PWR_NUM"="PWR_NUM" AND "X_SNI_FUEL_PLN_STP_DTL_P"."PLN_GAL_QTY"="PLN_GAL_QTY")
      10 - filter("X_SNI_FUEL_PLN_STP_DTL_P"."PWR_NUM"="X_SNI_FUEL_CMPLY_DTL_P"."PWR_NUM" AND
                  "X_SNI_FUEL_PLN_STP_DTL_P"."PLN_DTTM"="X_SNI_FUEL_CMPLY_DTL_P"."PLN_DT")
      12 - filter("R1"=1)
      13 - filter(ROW_NUMBER() OVER ( PARTITION BY "PWR_NUM","PLN_DTTM" ORDER BY
                  INTERNAL_FUNCTION("PLN_STP_DTL_ID") DESC )<=1)
      16 - access("X_SNI_FUEL_PUR_TXN_PRD_P"."FUEL_PUR_TXN_ID"="from$_subquery$_003"."FUEL_PUR_TXN_ID")
      17 - filter("X_SNI_FUEL_PUR_TXN_PRD_P"."PS_CURR_IND"=1)
      19 - access("X_SNI_FUEL_PUR_TXN_P"."DRV_NUM"="XO_E_PER_ASSIGNMENT_P"."DRV_NUM"(+))
           filter("X_SNI_FUEL_PUR_TXN_P"."TXN_DTTM"<="XO_E_PER_ASSIGNMENT_P"."ASN_EFF_END_DT"(+) AND
                  "X_SNI_FUEL_PUR_TXN_P"."TXN_DTTM">="XO_E_PER_ASSIGNMENT_P"."ASN_EFF_STRT_DT"(+))
      20 - filter("X_SNI_FUEL_PUR_TXN_P"."PS_CURR_IND"=1)
      21 - filter("XO_E_PER_ASSIGNMENT_P"."DRV_NUM"(+) IS NOT NULL AND
                  "XO_E_PER_ASSIGNMENT_P"."ACTV_EMP_IND"(+)=1 AND "XO_E_PER_ASSIGNMENT_P"."PS_CURR_IND"(+)=1 AND
                  "XO_E_PER_ASSIGNMENT_P"."PRSN_TYP_RNK_NUM"(+)=1)
    Note
       - SQL plan baseline "SYS_SQL_PLAN_160e8c87962a1dc5" used for this statement
    55 rows selected.

    Hello
    I think you have some issues with your logic here. For example
    LEFT OUTER JOIN
      SEA_DWSTG.X_SNI_TRK_STP_P X_SNI_TRK_STP_P
    ON X_SNI_FUEL_PLN_STP_DTL_P.PRVD_TRK_STP_CD = X_SNI_TRK_STP_P.CMDTA_CD
    ON X_SNI_FUEL_PUR_TXN_P.FUEL_PUR_TXN_ID     = X_SNI_FUEL_CMPLY_DTL_P.FUEL_PUR_TXN_ID,
      SEA_DWSTG.X_SNI_FUEL_PUR_TXN_PRD_P X_SNI_FUEL_PUR_TXN_PRD_P
    WHERE (1                                      = 1)
    AND (X_SNI_FUEL_PUR_TXN_PRD_P.FUEL_PUR_TXN_ID = X_SNI_FUEL_PUR_TXN_P.FUEL_PUR_TXN_ID
    AND X_SNI_FUEL_PUR_TXN_PRD_P.PS_CURR_IND      = 1
    AND X_SNI_FUEL_PUR_TXN_P.PS_CURR_IND          = 1)You're using a left outer join but then you're specifying a where clause which means this has to be an inner join. And specifically what is this bit doing...
    ON X_SNI_FUEL_PUR_TXN_P.FUEL_PUR_TXN_ID     = X_SNI_FUEL_CMPLY_DTL_P.FUEL_PUR_TXN_ID,
      SEA_DWSTG.X_SNI_FUEL_PUR_TXN_PRD_P X_SNI_FUEL_PUR_TXN_PRD_PYou appear to be mixing ANSI join syntax with oracle style syntax i.e you've got a comma after X_SNI_FUEL_CMPLY_DTL_P.FUEL_PUR_TXN_ID, and then you're specifying another table. Why isn't this using ANSI syntax?
    And what's the deal with mixing the left and right outer joins? Try to make it consistent.
    You're accessing X_SNI_FUEL_PLN_STP_DTL_P twice but as far as I can tell you could avoid the second access in the subquery by bringing the ROW_NUMBER function into the main select and wrapping it in an inline view to do the filtering.
    i.e.
    SELECT
    FROM
        SELECT  XO_E_PER_ASSIGNMENT_P.*,
                X_SNI_FUEL_PUR_TXN_P.*
                X_SNI_FUEL_PLN_STP_DTL_P.*
                X_SNI_FUEL_CMPLY_DTL_P.*
                X_SNI_TRK_STP_P.*
                X_SNI_FUEL_PUR_TXN_PRD_P.*
                ROW_NUMBER () OVER (PARTITION BY pwr_num, pln_dttm,pln_gal_qty ORDER BY pln_stp_dtl_id DESC) r1
        FROM
          SEA_DWSTG.XO_E_PER_ASSIGNMENT_P XO_E_PER_ASSIGNMENT_P
        RIGHT OUTER JOIN
          SEA_DWSTG.X_SNI_FUEL_PUR_TXN_P X_SNI_FUEL_PUR_TXN_P
          ON X_SNI_FUEL_PUR_TXN_P.DRV_NUM = XO_E_PER_ASSIGNMENT_P.DRV_NUM
          AND X_SNI_FUEL_PUR_TXN_P.TXN_DTTM BETWEEN XO_E_PER_ASSIGNMENT_P.ASN_EFF_STRT_DT AND XO_E_PER_ASSIGNMENT_P.ASN_EFF_END_DT
          AND XO_E_PER_ASSIGNMENT_P.PS_CURR_IND      = 1
          AND XO_E_PER_ASSIGNMENT_P.DRV_NUM         IS NOT NULL
          AND XO_E_PER_ASSIGNMENT_P.ACTV_EMP_IND     = 1
          AND XO_E_PER_ASSIGNMENT_P.PRSN_TYP_RNK_NUM = 1
        LEFT OUTER JOIN
          SEA_DWSTG.X_SNI_FUEL_PLN_STP_DTL_P X_SNI_FUEL_PLN_STP_DTL_P
        RIGHT OUTER JOIN
          SEA_DWSTG.X_SNI_FUEL_CMPLY_DTL_P X_SNI_FUEL_CMPLY_DTL_P
          ON (X_SNI_FUEL_PLN_STP_DTL_P.PWR_NUM = X_SNI_FUEL_CMPLY_DTL_P.PWR_NUM)
          AND X_SNI_FUEL_PLN_STP_DTL_P.PLN_DTTM = X_SNI_FUEL_CMPLY_DTL_P.PLN_DT
          AND (X_SNI_FUEL_PLN_STP_DTL_P.pln_stp_dtl_id, X_SNI_FUEL_PLN_STP_DTL_P.pwr_num, X_SNI_FUEL_PLN_STP_DTL_P.pln_gal_qty)
        LEFT OUTER JOIN
          SEA_DWSTG.X_SNI_TRK_STP_P X_SNI_TRK_STP_P
        ON X_SNI_FUEL_PLN_STP_DTL_P.PRVD_TRK_STP_CD = X_SNI_TRK_STP_P.CMDTA_CD
        ON X_SNI_FUEL_PUR_TXN_P.FUEL_PUR_TXN_ID     = X_SNI_FUEL_CMPLY_DTL_P.FUEL_PUR_TXN_ID, 
        SEA_DWSTG.X_SNI_FUEL_PUR_TXN_PRD_P X_SNI_FUEL_PUR_TXN_PRD_P
        WHERE (1                                      = 1)
        AND (X_SNI_FUEL_PUR_TXN_PRD_P.FUEL_PUR_TXN_ID = X_SNI_FUEL_PUR_TXN_P.FUEL_PUR_TXN_ID
        AND X_SNI_FUEL_PUR_TXN_PRD_P.PS_CURR_IND      = 1
        AND X_SNI_FUEL_PUR_TXN_P.PS_CURR_IND          = 1)
    WHERE
        r1 = 1From a performance perspective it's not helping that you're doing full table scans in a nested loop. I think you need to clarify some of your logic and remove the unnecessary outer joins and then you can look to address some of the performance issues.
    David

  • Will this query work?

    Email id in one of my tables A is stored in the format -- email://[email protected]
    If I want this to get displayed as just [email protected] where X is any address and its value is varying for eg -- [email protected] or [email protected] etc
    Can I give my query like this?
    insert into A values(select trim(substr(email,1,9)); -- I am trying to trim email://
    Will trim(substr) work?
    Please advise

    user6440749 wrote:
    Email id in one of my tables A is stored in the format -- email://[email protected]
    If I want this to get displayed as just [email protected] where X is any address and its value is varying for eg -- [email protected] or [email protected] etc
    Can I give my query like this?
    insert into A values(select trim(substr(email,1,9)); -- I am trying to trim email://
    Will trim(substr) work?
    Please adviseYou are on the right track. Just that you need to change the substr function a little bit.
    You just need to remove the email:// (8 characters) and get the string from 9th character. So, it would be something like
    insert into A values(select trim(substr(email,9))); -Arun

  • Does this query work on your DB?

    I'm on 9.2.0.4. The following query fails because it can't see the u.username column of the inner-inner query. But if I un-nest it by one level it works fine. It's as if the inline view hides the column names of the outermost query.
    Is it supposed to work this way, or have I hit a bug?
    If it works on your installation, could you please tell me your version number? Thanks.
    SELECT u.username
         ,(SELECT object_name
           FROM (SELECT o.object_name
                 FROM   all_objects o
                 WHERE  o.owner = u.username
                 ORDER BY o.object_id DESC)
           WHERE rownum = 1
          )  greatest_object_id
    FROM   all_users u
    ERROR at line 5:
    ORA-00904: "U"."USERNAME": invalid identifier
    SELECT u.username
         ,(SELECT count(*)
           FROM   all_objects o
           WHERE  o.owner = u.username) object_count
    FROM   all_users u
    USERNAME    OBJECT_COUNT
    SYS                 2851
    SYSTEM                31
    HANSENE               15
    ...

    I tested in 9.2.0.6 and didn't work either. I think it should work... can be a bug, not sure. An alternate way is:
    select
    u.username,
    (select o.object_name from all_objects o where o.owner = u.username and o.object_id = (select max(m.object_id) from all_objects m where m.owner = o.owner)) greatest_object_id
    from
    all_users u;

  • How can this pattern work? need help!!

    the model i need have 3layers:JSP+EJB+SocketServer, i know EJB can act as Socket Client(not Server),but the
    main problem is that i must use a .dll or .lib file(written in
    c) in EJB to packge the socket data.someone says EJB
    can use JNI while EJB Spec won't allow it, i dont't want
    to take the risk also.Is there any other way can work?
    (use runtime in EJB?)
    if EJB can't work in this pattern,can i have another choice? (JSP and SocketServer can't be replaced)
    NEED HELP!

    Use the Mediator pattern.

  • Buddy list all gray--how can this not work??

    I've got iChat 3.1.8 and only opened it when i got a little Logitec USB camera. Plugged everything in, set all the settings, and added my buddy (another Mac user). I could not initiate a video chat because my buddy list names and icons are all gray. There are NO green icons at all. But she said I showed up just fine in her buddy list, and when she initiated the chat it worked perfectly. We had a nice chat. But when we tried again from my end, still no color in my life.
    The camera has worked fine since I plugged it in. I bought and installed iChatUSBCam v2.2.1, which allowed me to set a few more settings. Alas, nothing has changed.
    I've read this question a few times on the board and--most frustrating--they all seem to say "Oh, it worked itself out." But mine isn't working itself out. Camera and microphone are enabled. No one is blocked. I'm lost.
    ibook G4   Mac OS X (10.4.10)  

    Hi M Smith 1,
    Welcome to the Apple Discussions
    In System Preferences > Sharing > Firewall tab is the Firewall On ?
    Have you set the iChat ports in a New options if it Is ?
    Did those ports include 5190 on UDP ?
    If Yes to these three question use the Advanced button.
    Does this have the "Block UDP Traffic" item ticked ?
    If so deselect it.
    The iChat ports also need to be open in your modem and any separate router.
    If Port Forwarding was used here it must point to the IP that your computer is getting or using. ( See System Preferences > Network > (Select connection method) > TCP/IP tab )
    On some modems and or routers the forwarding or use of TCP and UDP protocols on port 5190 seems to cause a conflict.
    iChat can have the login to AIM and text chatting moved to a different port.
    iCHat > Preferences > Accounts
    Select the AIM or @mac account on the left
    Select the Server Settings tab
    Whilst Logged out of AIM change the port to 443.
    If all these do not work go to Users/(your Account)/Library/Preferences and delete com.apple.ichat.AIM.plist and restart ichat
    10:55 AM Monday; July 23, 2007

  • Can this Printer Work

    Hello;
    I have a Power Mac G4 running OS 10.4.7
    My Epson Photo 1280 works great, however I would also like to run my HP Laser Jet 4P. The Laser Jer 4P has the Centronics Type plug on the rear and also a what appears to be a female 9 pin serial connector. Is there anything I can buy to hook this Laser Jet 4P to a USB Port on the G4 ? Not looking for any fancy printing, just basics. I did go to the HP download site and down loaded the Driver
    Ljlegacy-en.sit, but have no idea what to do with it now sitting on my desktop.
    Thank You
    Paul

    Kappy;
    I down loaded ' The Unarchiver'. It unzipped and then I ran the installer 'Ljlegacy-en.sit'
    The installer started to search MAC HD80 and said there were 503 items to be installed.
    Then up came the following msg;
    "A File named 'current' on Mac HD80 has the same name as a file that needs to be installed"
    Cancel to stop install or Delete to replace that folder
    I aborted at that point. Can I replace that folder ? What if others such messages come up, can they be replaced also ?
    Any other thing I may run into on installing the HP Laserjet 4P drivers ?
    Thank You
    Paul

  • Why doesnt this query work on CF when it works fine on MYSQL?

    Topic says it all. I can run this through mysql console and
    get the result i need but when i place it inside a cfquery it wont
    process.
    SET @saldo=20000;
    SELECT
    IF(co.transtipo=0,@saldo:[email protected],@saldo:=@saldo+t.transmonto),
    @saldo:[email protected],
    t.transid,
    t.cuentaid,
    t.operacionid,
    t.fechatrans,
    t.voucher,
    t.cheque,
    t.transtitular,
    t.transmonto,
    t.transdetalle,
    t.modificado,
    co.transtipo,
    co.operacion
    FROM cuentastrans t
    LEFT JOIN cuentasoperacion co ON
    t.operacionid=co.operacionid
    WHERE t.cuentaid= 7
    ORDER BY t.fechatrans ASC

    Thank you for the info, here is my robust:
    [Table (rows 30 columns
    IF(CO.TRANSTIPO=0,@SALDO:[email protected],@SALDO=@SALDO+T.TRANSMONTO),
    TRANSID, CUENTAID, OPERACIONID, FECHATRANS, VOUCHER, CHEQUE,
    TRANSTITULAR, TRANSMONTO, TRANSDETALLE, MODIFICADO, TRANSTIPO,
    OPERACION):
    [IF(CO.TRANSTIPO=0,@SALDO:[email protected],@SALDO=@SALDO+T.TRANSMONTO):
    coldfusion.sql.QueryColumn@fc48ce] [TRANSID:
    coldfusion.sql.QueryColumn@10fdc46] [CUENTAID:
    coldfusion.sql.QueryColumn@469b16] [OPERACIONID:
    coldfusion.sql.QueryColumn@16fcbc0] [FECHATRANS:
    coldfusion.sql.QueryColumn@a9be7a] [VOUCHER:
    coldfusion.sql.QueryColumn@184a49] [CHEQUE:
    coldfusion.sql.QueryColumn@b525a6] [TRANSTITULAR:
    coldfusion.sql.QueryColumn@badda8] [TRANSMONTO:
    coldfusion.sql.QueryColumn@2e6d14] [TRANSDETALLE:
    coldfusion.sql.QueryColumn@1fb3f37] [MODIFICADO:
    coldfusion.sql.QueryColumn@1f35ded] [TRANSTIPO:
    coldfusion.sql.QueryColumn@9b967b] [OPERACION:
    coldfusion.sql.QueryColumn@b49cf1] ] is not indexable by
    IF(CO.TRANSTIPO=0
    Now to the ":=" statement...
    http://dev.mysql.com/doc/refman/5.0/en/user-variables.html
    This is an example on the documentation
    mysql> SET @t1=0, @t2=0, @t3=0;
    mysql> SELECT @t1:=(@t2:=1)+@t3:=4,@t1,@t2,@t3;
    You can run that on your sql console and check the results.
    Perhaps there is another way to write the statement?

Maybe you are looking for