How to write the SQL for the following

ID     PRODUCT     LEAD_FLAG     SALES_VOLUME
1     A     Y     100
1     B     N     200
1     C     N     300
1     D     N     400
2     A     N     10
2     B     Y     20
2     C     N     30
2     D     N     40
I need to calculate the incentive for each ID. The rule is for an ID:
if the the lead flag for a product is N, then check the sales_volume of the product whose lead_flag is Y (product A in case of ID 1, product B in case of ID 2). if the sales_volume of the product with lead_flag = Y is greater than a NUMBER (this NUMBER varies from product to product. for product A it is 20, for product B it is 25, C it is 30 and D it is 40) then incentive = (sales_volume of the product with lead flag N) * 100.

Hello, I presume the NUMBER you refer to will be held in a table column somewhere? I'm calling it threshold_num in the test data below (and rec_id instead of ID):
WITH test_data AS (
SELECT 1 REC_ID, 'A' PRODUCT, 'Y' LEAD_FLAG,  100 SALES_VOLUME FROM DUAL UNION ALL
SELECT 1, 'B','N', 200 FROM DUAL UNION ALL
SELECT 1, 'C','N', 300 FROM DUAL UNION ALL
SELECT 1, 'D','N', 400 FROM DUAL UNION ALL
SELECT 2, 'A','N', 10 FROM DUAL UNION ALL
SELECT 2, 'B','Y', 20 FROM DUAL UNION ALL
SELECT 2, 'C','N', 30 FROM DUAL UNION ALL
SELECT 2, 'D','N', 40 FROM DUAL),
test_ref_data AS (
SELECT 'A' PRODUCT, 20 threshold_num FROM DUAL UNION ALL
SELECT 'B', 25 FROM DUAL UNION ALL
SELECT 'C', 30 FROM DUAL UNION ALL
SELECT 'D', 40 FROM DUAL)
-- end test data
SELECT td1.REC_ID, td1.PRODUCT, CASE WHEN td2.PRODUCT IS NOT NULL THEN td1.sales_volume * 100 ELSE 0 END incentive
  FROM test_data td1
   LEFT JOIN (
    SELECT td2.PRODUCT, SUM(sales_volume) sales_volume
     FROM test_data td2
     JOIN test_ref_data trd
        ON (td2.PRODUCT = trd.PRODUCT)
   WHERE td2.lead_flag = 'Y'
    GROUP BY td2.PRODUCT, trd.threshold_num HAVING SUM(td2.sales_volume) > trd.threshold_num) td2
    ON (td1.PRODUCT = td2.PRODUCT)
WHERE td1.lead_flag = 'N';
    REC_ID PROD  INCENTIVE
         2 A       1000
         2 D          0
         1 D          0
         1 B          0
         2 C          0
         1 C          0
6 rows selected.And two tips: it's always helps to put {noformat}{noformat} before and after your code for readability, and also to provide expected sample output.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                   

Similar Messages

  • How to write a query for the given scenario ?

    Hi All ,
    I am having two tables EMP, DEPT with the below data.
    EMP TABLE :--
    EID     ENAME     JOB     SAL     DEPID
    111     RAM     MANAGER     1500     10
    222     SAM     ASST MANAGER     2000     20
    333     KALA     CLERK     2500     10
    444     BIMA     MANAGER     3000     20
    555     CHALA     MANAGER     3500     30
    666     RANI     ASST MANAGER     4000     10
    777     KAMAL     MANAGER     2400     10
    DEPT TABLE :--
    DEPID     DNAME
    10     XX
    20     YY
    30     ZZ
    Q1 : I want the sum of salary of each department and for the particular job . Here in each departmant manager, asst. manager, clerk posts are there .
    I want to display the result like below ....
    JOB     10     20     30
    MANAGER     3900     3000     3500
    ASST MANAGER 4000     2000     NULL
    CLERK     2500     NULL     NULL
    please tell me how to write a sql query ?
    Thanks
    Sai

    In general case, you cannot write this query.
    This is one of the limits of relational database concepts. The number of columns must be known up-front. In the SELECT clause, you have to list and name all columns returned by the query. So you have to know number of departments. (There are some workarounds - you can return one column with concatenated values for all departments, separated by space character).
    If you know that you have 3 departments then you qurey will return 4 columns:
    SELECT
       e.job,
       SUM ( CASE WHEN d.deptid = 10 THEN e.sal ELSE NULL END) d10,
       SUM ( CASE WHEN d.deptid = 20 THEN e.sal ELSE NULL END) d20,
       SUM ( CASE WHEN d.deptid = 30 THEN e.sal ELSE NULL END) d30
    FROM dept d, emp e
    WHERE d.deptno = e.deptno
    GROUP BY e.job

  • Trying to find out the sql for the below 3 values

    HI Experts,
    I am trying to find the sql that can give me the values for the below three values. can some one Help me out getting these ?
    Free buffer waits (%)
    Local write wait (%)
    Latch: cache buffer chains (%)
    Actually these are the metrics which are available in OEM for the DB releases up to 9i. Post 9i releases , these metrics are obsoleted.
    So, trying to find the sql for these and use them as an UDM for the 10g and 11g DB's
    Thanks in Advance.
    Thanks,
    Naveen kumar.

    And is there any why to find using what sql the metrci is formed ?

  • How to write a query for the following issue

    Hello,
    I would like to write a query to display the result in the following format 
    Item
    Categort1
    Categort2
    Categort3
    Categort4
    Categort5
    Categort6
    Min
    Max
    Avg
    Min
    Max
    Avg
    Min
    Max
    Avg
    Min
    Max
    Avg
    Min
    Max
    Avg
    Min
    Max
    Avg
    01
    02
    03
    04
    For every item for the category i need to find Min,Max and Avg from the Value column
    Table structure is as follows
    ID
    Item Id
    Item
    Category
    value
    1
    01
    A
    Categort1
    1
    2
    01
    A
    Categort1
    2
    3
    01
    A
    Categort1
    3
    4
    02
    B
    Categort2
    7
    5
    02
    B
    Categort2
    8
    6
    03
    C
    Categort3
    6
    7
    04
    D
    Categort4
    12
    8
    04
    D
    Categort4
    14

    SELECT ItemID,
    MIN(CASE WHEN Category = 'Categort1' THEN value END) AS Min_category1,
    MAX(CASE WHEN Category = 'Categort1' THEN value END) AS Max_category1,
    AVG(CASE WHEN Category = 'Categort1' THEN value END) AS Avg_category1,
    MIN(CASE WHEN Category = 'Categort2' THEN value END) AS Min_category2,
    MAX(CASE WHEN Category = 'Categort2' THEN value END) AS Max_category2,
    AVG(CASE WHEN Category = 'Categort2' THEN value END) AS Avg_category2,
    MIN(CASE WHEN Category = 'Categort6' THEN value END) AS Min_category6,
    MAX(CASE WHEN Category = 'Categort6' THEN value END) AS Max_category6,
    AVG(CASE WHEN Category = 'Categort6' THEN value END) AS Avg_category6
    FROM Table
    GROUP BY ItemID
    The format can be achieved using tools like SSRS
    Please Mark This As Answer if it helps to solve the issue Visakh ---------------------------- http://visakhm.blogspot.com/ https://www.facebook.com/VmBlogs

  • How to write selection Query for the following requirment.

    Hi All,
    I am new to ABAP, I need a help ,
    I need to select all plants(WERKS) from MARC at Plant/Material level,
    then I need to take all sales organozation(VKORG) from T001w,
    then I need the company code(BUKRS) from TVKO based on VKORG,
    then I need the currency key(WAERS) from T001 based on BUKRS,
    Can any one help me in writing selection Query for the same?
    Thanks All,
    Debrup.

    Hi,
    Its easy for you if you learn SELECT with JOIN to complete your task. So SEARCH the forum with SELECT statement and you will get a lot of examples using which you can write your own.
    If you struck up anywhere revert back.
    Regards
    Karthik D

  • How to write a rule for the scnario...

    Hi ,
    Any body please tell me how to write a HFM rule for the following scnario.
    Pull<Parent Currency> value for base members from ACTUAL_EURO scenario and replaces <Parent Currency> value of for base members in ACTUAL scenario. At the end of this process, the actual scenario holds functional currency in <Entity Currency>, EURO in <Parent Currency>.
    It's Urgent.
    Thanks in Advance,
    Mohan

    sub calculate()
    if hs.scenario.member="ACTUAL" then
    Elist=hs.entity.list("","[Base]")
    if hs.value.istranscur=TRUE then
    if hs.entity.isbase("","")=TRUE then
    hs.exp "A#ALL=A#ALL.S#ACTUAL_EURO"
    end if
    end if
    end if
    end sub
    While running the Rule file getting the below error
    An error occurred.
    Error: 800456C8
    Log:
    Load started at: 12:06:02
    Number of Errors: 1
    Number of Warnings: 0
    <?xml version="1.0"?>
    <EStr><Ref>{151D9809-D203-45E2-BA63-EDDF93FF758C}</Ref><User/><DBUpdate>1</DBUpdate><ESec><Num>-2147214193</Num><Type>0</Type><DTime>6/3/2010 12:06:02 PM</DTime><Svr>ALVHYPW05</Svr><File>CHsvCalculate.cpp</File><Line>1773</Line><Ver>9.3.1.0.2042</Ver></ESec></EStr>
    Load ended at: 12:06:02
    Elapsed time: 00:00:00
    Thanks,
    RON

  • How to write processing code for the Inbound IDOC to the R/3 ??

    i m having a file -> XI-->R/3 scenario,
    IDOC is being sent from XI to R/3,
    can u guide to me to write a processing code for the Inbound IDOC to the R/3,
    since i m new to ABAP and ALE technology, can we provide me any blog for doing that.......or guide me....

    Hi Sudeep
    Simple File to Idoc scenarion blog
    /people/ravikumar.allampallam/blog/2005/06/24/convert-any-flat-file-to-any-idoc-java-mapping - Any flat file to any Idoc
    Also see the blog
    <a href="/people/ravikumar.allampallam/blog/2005/02/23/configuration-steps-required-for-posting-idocsxi Steps for Posting IDOC's</a> by Ravikumar.
    Configuration of IDOC adapter
    http://help.sap.com/saphelp_nw04/helpdata/en/96/791c42375d5033e10000000a155106/frameset.htm
    Regards
    Santhosh
    *Reward points if useful*

  • How to write customer exit for the variable

    Hi Experts,
    I have a requirement to create the variable, the scenaria is like this..
    I need to create the variable which gives the period/year values,if yours enters the values 05.2007 then the variable should return the first monthe the year i.e.01.2007.
    I hope it can be done by writing the customer exit..but iam unware how to achieve this.
    Please explain me step by step and cope for customer exit to done this.
    Points will be awarded
    Suraj.

    hi Suraj,
    there should variable sap exit for first month,
    for customer exit, check this how to doc for steps
    https://websmp210.sap-ag.de/~sapdownload/011000358700002762582003E/HowToDeriveVariableValue.pdf
    your code may look like
      INCLUDE ZXRSRU01                                                   *
      DATA: L_S_RANGE TYPE RSR_S_RANGESID.
      DATA: LOC_VAR_RANGE LIKE RRRANGEEXIT.
      CASE I_VNAM.
      WHEN 'your 1st month variable'.
        IF I_STEP = 2.                                  "after the popup
          LOOP AT I_T_VAR_RANGE INTO LOC_VAR_RANGE
                  WHERE VNAM = 'your user input variable'.
            CLEAR L_S_RANGE.
            L_S_RANGE-LOW      = LOC_VAR_RANGE-LOW(4)."low value, e.g.200001
            L_S_RANGE-LOW+4(2) = '01'.
            L_S_RANGE-SIGN     = 'I'.
            L_S_RANGE-OPT      = 'EQ'.
            APPEND L_S_RANGE TO E_T_RANGE.
            EXIT.
          ENDLOOP.
        ENDIF.
      ENDCASE.
    hope this helps.

  • How to write  complex sql for this

    Hi ALL,
    I have a requirement like this
    I have 5 tables which i have to join to get the result
    but there no join column to 2 other table.
    I want to get all the applications using cobal,running on UNIX.
    How to write the query for this
    1.APP
    APP_i DESC
    1 Accounts
    2 Payments
    3 order transfer
    4 Order processing
    2.Techgy
    techid techdesc
    1 cobal
    2 Java
    3.APP_Techgy
    APP_I Techid
    1 1
    2 1
    3 1
    4 2
    4.Pltfrm
    pltfmid pltfrmdesc
    1 Windows NT
    2 UNIX
    5.APP_Pltfrm
    APP_I pltfrmid
    1 1
    2 1
    3 2
    4 2
    ouput must be
    APP_i Desc techDESC pltfrmdesc
    3 ordertranfer Cobal UNIX
    Thanks in advance

    This ('descr' in place of 'desc')?
    SQL> select a.app_i, a.descr, t.techdesc, p.pltfrmdesc
    from app_techgy atc,
       app a,
       techgy t,
       app_pltfrm ap,
       pltfrm p
    where atc.techid = t.techid
    and atc.app_i = a.app_i
    and atc.app_i = ap.app_i
    and ap.pltfrmid = p.pltfmid
    order by a.app_i
         APP_I DESCR                TECHDESC             PLTFRMDESC         
             1 accounts             cobal                windows nt         
             2 payments             cobal                windows nt         
             3 order transfer       cobal                unix               
             4 order processing     java                 unix               
    4 rows selected.

  • How to frame a SQL for the below Query

    i have a SQL query
    select x,y from table1 where x=1
    output
    x y
    1 a
    1 b
    where a means alpha and b means beta
    select x,z from table2 where x=1
    Output
    x z
    1 B
    How do i build a query to achieve a following output
    x z y1 y2
    1 b alpha beta
    Please noete : Instead of 'a' and 'b' i want it to be replaced by words and
    i want two rows value to appear in one column together....

    Maybe this is what you want ... I'm under the impression of trying to catch a moving target here.
    WITH tb_clr_doc_version_defs AS (SELECT 'A' datatype_cd,
                                            13  doctype_id
                                       FROM dual
                                      UNION
                                     SELECT 'A' datatype_cd,
                                            14  doctype_id
                                       FROM dual
         tb_clr_doc_field_defs AS (SELECT 'AccountNb_ID' fieldname_nm,
                                          13             doctype_id
                                       FROM dual
                                    UNION
                                   SELECT 'TaxIDNb_NO' fieldname_nm,
                                          13           doctype_id
                                       FROM dual
    SELECT datatype,
           MAX(DECODE(fieldname_nm, 'AccountNb_ID', fieldname_nm, NULL)) fieldname_nm1,
           MAX(DECODE(fieldname_nm, 'TaxIDNb_NO'  , fieldname_nm, NULL)) fieldname_nm2
      FROM (SELECT t1.doctype_id,
                   DECODE(t1.datatype_cd, 'A', 'afp', 'L', 'line', 'M', 'mixed', t1.datatype_cd) datatype,
                   t2.fieldname_nm
              FROM tb_clr_doc_version_defs t1,
                   tb_clr_doc_field_defs   t2
             WHERE t1.doctype_id = t2.doctype_id(+)
    GROUP BY doctype_id, datatype
      ;

  • How to group using SQL for the required output.

    hi all,
    i'm currently using oracle 10.2.0.4.0
    create table script :
    CREATE TABLE FORTEST
    ( gpno VARCHAR2(10 BYTE),
      classnumber  VARCHAR2(10 byte),
      age_min NUMBER,
      age_max NUMBER,
      amount NUMBER)insert statement:
    insert into fortest  (GPNO,classnumber,age_min,age_max,amount) values
    ('G123' , 01,0,29,1)
    insert into fortest  (GPNO,classnumber,age_min,age_max,amount) values
    ('G123' , 01,30,35,2)
    insert into fortest  (GPNO,classnumber,age_min,age_max,amount) values
    ('G123' , 01,36,40,3)
    insert into fortest  (GPNO,classnumber,age_min,age_max,amount) values
    ('G123' , 02,0,29,1)
    insert into fortest  (GPNO,classnumber,age_min,age_max,amount) values
    ('G123' , 02,30,35,2)
    insert into fortest  (GPNO,classnumber,age_min,age_max,amount) values
    ('G123' , 02,36,40,5)
    insert into fortest  (GPNO,classnumber,age_min,age_max,amount) values
    ('G123' , 03,0,29,1)
    insert into fortest  (GPNO,classnumber,age_min,age_max,amount) values
    ('G123' , 03,30,35,2)
    insert into fortest  (GPNO,classnumber,age_min,age_max,amount) values
    ('G123' , 03,36,40,3)
    insert into fortest  (GPNO,classnumber,age_min,age_max,amount) values
    ('G124' , 01,0,29,1)
    insert into fortest  (GPNO,classnumber,age_min,age_max,amount) values
    ('G124' , 01,30,35,2)
    insert into fortest  (GPNO,classnumber,age_min,age_max,amount) values
    ('G124' , 01,36,40,3) output required:
    gpno    classnumber    age_min    age_max    amount
    G123    1,3                0        29        1
    G123    1,3                30       35        2
    G123    1,3                36       40        3
    G123    2                  0        29        1
    G123    2                  30       35        2
    G123    2                  36       40        5
    G124    1                  0        29        1
    G124    1                  30       35        2
    G124    1                  36       40        3since for gpno g123, classnumber 1 and 3, the rates are same across all age_min and age_max they need to be grouped together.
    even though gpno 123 classnumber 2 has same rates as classesnumber 1 and 3 for age bands 0 to 29 and 30 to 35,
    the rates are different for age bands 36 to 40. so it should not be grouped together. how can i do this in SQL
    any help is appreciated.
    thanks in advance.

    Hi,
    Tricky problem!
    Unfortunately, LISTAGG was only introduced in Oracle 11.2. About half of the complexity here is the string aggregation, that is, forming the list of classnumbers, such as '1,3', using only functions available in Oracle 10.2.
    Here's one solution:
    WITH     got_gpno_classnumber_cnt   AS
         SELECT     gpno, classnumber, age_min, age_max, amount
         ,     COUNT (*) OVER ( PARTITION BY  gpno
                                      ,            classnumber
                          )   AS gpno_classnumber_cnt
         FROM    fortest
    --     WHERE     ...     -- If you need any filtering, this is where it goes
    ,     pairs          AS
         SELECT    a.gpno
         ,       a.classnumber
         ,       MIN (b.classnumber)
                    OVER ( PARTITION BY  a.gpno
                              ,                    a.classnumber
                      )     AS super_classnumber
         FROM       got_gpno_classnumber_cnt  a
         JOIN       got_gpno_classnumber_cnt  b  ON   a.gpno     = b.gpno
                                      AND  a.age_min     = b.age_min
                                    AND  a.age_max     = b.age_max
                                    AND  a.amount     = b.amount
                                    AND  a.gpno_classnumber_cnt
                                            = b.gpno_classnumber_cnt
         GROUP BY  a.gpno
         ,            a.classnumber
         ,       b.classnumber
         HAVING       COUNT (*)     = MIN (a.gpno_classnumber_cnt)
    ,     got_rnk          AS
         SELECT DISTINCT     
                 gpno, classnumber, super_classnumber
         ,     DENSE_RANK () OVER ( PARTITION BY  gpno
                                   ,                    super_classnumber
                                   ORDER BY          classnumber
                           )         AS rnk
         FROM    pairs
    ,     got_classnumbers     AS
         SELECT     gpno, classnumber, super_classnumber
         ,      SUBSTR ( SYS_CONNECT_BY_PATH (classnumber, ',')
                       , 2
                     )     AS classnumbers     
         FROM     got_rnk
         WHERE     CONNECT_BY_ISLEAF = 1
         START WITH     rnk             = 1
         CONNECT BY     rnk             = PRIOR rnk + 1
              AND     gpno             = PRIOR gpno
              AND     super_classnumber  = PRIOR super_classnumber
    SELECT DISTINCT
           g.gpno
    ,       c.classnumbers
    ,       g.age_min
    ,       g.age_max
    ,       g.amount
    FROM       got_gpno_classnumber_cnt  g
    JOIN       got_classnumbers         c  ON   c.gpno        = g.gpno
                                 AND  c.classnumber  = g.classnumber
    ORDER BY  g.gpno
    ,            c.classnumbers
    ;Output (just as you requested):
    GPNO       CLASSNUMBERS       AGE_MIN    AGE_MAX     AMOUNT
    G123       1,3                      0         29          1
    G123       1,3                     30         35          2
    G123       1,3                     36         40          3
    G123       2                        0         29          1
    G123       2                       30         35          2
    G123       2                       36         40          5
    G124       1                        0         29          1
    G124       1                       30         35          2
    G124       1                       36         40          3

  • How to write a Query for the mentioned scenario.

    Hi All,
    Table A
    ID|| Start_Date||End_date||Rate
    1||01-Jan-2011||31-Mar-2011||0.8
    1||01-Apr-2011||31-Jun-2011||0.9
    I have a table like above. I want to write a query to display the result as below.
    ID|| Start_Date||Rate
    1||01-Jan-2011||0.8
    1||01-Feb-2011||0.8
    1||01-Mar-2011||0.8
    1||01-Apr-2011||0.9
    1||01-May-2011||0.9
    1||01-Jun-2011||0.9
    Kindly help.
    Thanks!
    GJ

    Try to read link mentioned by SB. It will make you more interactive to share your problems. And immediate reply too from experts.
    Check your solution below.
    SQL> ed
    Wrote file afiedt.buf
      1  WITH data1 AS
      2  (
      3  SELECT 1 id, TO_DATE('01-Jan-2011' , 'DD-Mon-YYYY') stdt,TO_DATE('31-Mar-2011' , 'DD-Mon-YYYY') endt, 0.8 rate FROM dual
      4  UNION ALL
      5  SELECT 1 id, TO_DATE('01-Apr-2011' , 'DD-Mon-YYYY') stdt,TO_DATE('30-Jun-2011' , 'DD-Mon-YYYY') endt, 0.9 rate FROM dual
      6  )
      7  SELECT id, ADD_MONTHS(stdt, level -1) st_dt, rate FROM data1
      8  CONNECT BY  level <= ROUND(MONTHS_BETWEEN(endt,stdt))
      9  AND rate= prior rate  /* stick to current line */
    10* AND prior sys_guid() IS NOT NULL  /* used to terminate the connect by loop */
    SQL> /
            ID ST_DT           RATE
             1 01-JAN-11         .8
             1 01-FEB-11         .8
             1 01-MAR-11         .8
             1 01-APR-11         .9
             1 01-MAY-11         .9
             1 01-JUN-11         .9
    6 rows selected.Thanks!
    Ashutosh
    Edited by: Ashu_Neo on Oct 8, 2012 11:57 AM

  • How to write Dynamic SQL for this SQL ?

    EXECUTE IMMEDIATE 'select COUNT(*) from dba_Tab_privs@' ||db_link|| ' WHERE Grantee <> 'DELETE_CATALOG_ROLE'
    AND Table_Name = 'LINK$'
    AND Grantee NOT IN (SELECT Grantee
    FROM dba_Role_privs
    WHERE Granted_Role = 'DBA')' into i using x;

    Hi bapalu,
    I take that x is the name of your db_link?
    If so,
    DECLARE
       i      NUMBER;
       x      dba_db_links.db_link%TYPE;
       stmt   VARCHAR2(255);
    BEGIN
       x := 'some_link';
       stmt :=
          'SELECT count(*)
             FROM dba_tab_privs@:db_link
            WHERE grantee <> ''DELETE_CATALOG_ROLE''
              AND table_name = ''LINK$''
              AND grantee NOT IN(SELECT grantee
                                   FROM dba_role_privs
                                  WHERE granted_role = ''DBA'')';
       EXECUTE IMMEDIATE REPLACE(stmt, ':db_link', x)
                    INTO i;
       dbms_output.put_line('The count: ' || i);
    END;Also, I think this is maybe not what you want:
    AND table_name = ''LINK$''Regards
    Peter

  • Aperture (3.4.1) no longer opens and the following message appears: There was an error opening the database for the library "/ Users / Andrea / Pictures / Aperture 3 Library.aplibrary." How can I solve this problem? Thanks

    I was using Aperture (3.4.1), when he appeared a notice that asked me to stop the Mac with the power button. When I restart Aperture no longer opens and the following message appears: There was an error opening the database for the library "/ Users / Andrea / Pictures / Aperture 3 Library.aplibrary."
    How can I solve this problem?
    Thanks

    After a system crash your Aperture Library may be corrupted, because Aperture may not have been able to finish the ongoing database transactions.
    Have you tried the Aperture Library First Aid Tools?
    Aperture 3 User Manual: Repairing and Rebuilding Your Aperture Library
    Try "Repair Database", and if this does not help: "Rebuild Database"
    Regards
    Léonie

  • How to write select query for all the user tables in database

    Can any one tell me how to select the columns from all the user tables in a database
    Here I had 3columns as input...
    1.phone no
    2.memberid
    3.sub no.
    I have to select call time,record,agn from all the tables in a database...all database tables have the same column names but some may have additional columns..
    Eg: select call time, record,agn from ah_t_table where phone no= 6186759765,memberid=j34563298
    Query has to execute not only for this table but for all user tables in the database..all tables will start with ah_t
    I am trying for this query since 30days...
    Help me please....any kind of help is appreciated.....

    Hi,
    user13113704 wrote:
    ... i need to include the symbol (') for the numbers(values) to get selected..
    eg: phone no= '6284056879'To include a single-quote in a string literal, use 2 or them in a row, as shown below.
    Starting in Oracle 10, you can also use Q-notation:
    http://download.oracle.com/docs/cd/E11882_01/server.112/e17118/sql_elements003.htm#i42617
    ...and also can you tell me how to execute the output of this script. What front end are you using? If it's SQL*Plus, then you can SPOOL the query to a file, and then execute that file, like this:
    -- Suppress SQL*Plus features that interfere with raw output
    SET     FEEDBACK     OFF
    SET     PAGESIZE     0
    -- Run preliminary query to generate main query
    SPOOL     c:\my_sql_dir\all_ah_t.sql
    SELECT       'select call time, record, agn from '
    ||       owner
    ||       '.'
    ||       table_name
    ||       ' where phone_no = ''6186759765'' and memberid = j34563298'
    ||       CASE
               WHEN ROW_NUMBER () OVER ( ORDER BY  owner          DESC
                              ,        table_name      DESC
                              ) = 1
               THEN  ';'
               ELSE  ' UNION ALL'
           END     AS txt
    FROM       all_tables
    WHERE       SUBSTR (table_name, 1, 4)     = 'AH_T'
    ORDER BY  owner
    ,       table_name
    SPOOL     OFF
    -- Restore SQL*Plus features that interfere with raw output (if desired)
    SET     FEEDBACK     ON
    SET     PAGESIZE     50
    -- Run main query:
    @c:\my_sql_dir\all_ah_t.sql
    so that i form a temporary view for this script as a table(or store the result in a temp table) and my problem will be solved..Sorry, I don't understand. What is a "temporary view"?

Maybe you are looking for

  • Why does my cinema display interpret "actual size" as 75% size?

    I just switched from a 19" CRT to a 20" Apple cinema display and in all of my design programs (Quark, Illustrator, Photoshop, etc) the "actual size" view is about 25% SMALLER than actual print size. Even web pages are reduced. Is there any way to rec

  • JDI: Cannot import development configuration into NWDS

    Hi everyone! I am trying to setup and use the Scenario 2+ for the JDI. So far, I have 1) created users and roles for the JDI 2) created a software component called com.company/WeekNumber 3) created a domain and a track in the CMS 4) imported required

  • Early 2009 mac pro, lion won't install

    Getting very frustrating... Download and go through all the steps and downloads additional files form online then says that i cannot install and the the lion file is damaged. I have downloaded twice and even went as far as formatting and re installin

  • S230u won't upgrade to 8.1

    Lots of info here about upgrading to 8.1 and I've read many of them.  My S230u Twist won't complete the process despite making sure that all updates, drives, etc are up to date.  Is there a process / troubleshooting apprach that should be usd to try

  • Desktop Integration for customized translator applications

    Hi, For the customized translator applications (trained systems) built using microsoft translator hub, is it possible to integrate them with MS Office and all other tools, servers and web applications that are automatically integrated to the out-of-t