Grouping query gives several lines

friends...

can someone check this query and tell me where I am wrong... I have to get a single line for each record... but I'm getting mutiple lines... in fact... I wrote this application in vb6 to ms access, but if you give a solution in oracle, I can change to ms access sql.
"select [stdentry.sno],[stdentry.branch],[stdentry.stdname],[stdentry.amtobepaid]," _
& "iif([feesdetail.paytype]='DD',sum([feesdetail.paidamt]),0) as totpaid," _
& "iif([feesdetail.paytype]='CASH',sum([feesdetail.paidamt]),0) as totpaid1 " _
& "from stdentry,feesdetail where " _
& "([feesdetail.delstat]='N') and [stdentry.sno]=[feesdetail.sno] and [stdentry.refundstat]='N' " _
& "group by [stdentry.sno],[stdentry.branch],[stdentry.stdname],[stdentry.amtobepaid],[feesdetail.paytype]"
Thanks and waiting with someone.

This is an ORACLE SQL and PL/SQL forum... Better, you ask your question in an appropriate forum...

You can check this too

"select [stdentry.sno],[stdentry.branch],[stdentry.stdname],[stdentry.amtobepaid]," _
& "sum(iif([feesdetail.paytype]='DD',[feesdetail.paidamt],0)) as totpaid," _
& "sum(iif([feesdetail.paytype]='CASH',[feesdetail.paidamt],0)) as totpaid1 " _
& "from stdentry,feesdetail where " _
& "([feesdetail.delstat]='N') and [stdentry.sno]=[feesdetail.sno] and [stdentry.refundstat]='N' " _
& "group by [stdentry.sno],[stdentry.branch],[stdentry.stdname],[stdentry.amtobepaid]"

Tags: Database

Similar Questions

  • SQL query, generate several lines in a value in a field

    I use the Oracle database. Imaging I have a table with a row as follows

    col1 |  col2. COL3

    "Str1" | "Str2". 4

    The value of col3 = 4 is expected to generate 4 rows as follows:

    col1 |  col2. COL3

    "Str1" | "Str2". 1

    "Str1" | "Str2". 2

    "Str1" | "Str2". 3

    "Str1" | "Str2". 4

    After several hours in front of the screen and stil no chance - how do I create such a select query?

    It will work

    Select * from test_table:

    COL1 COL2 COL3

    str1 str2 2

    strA, strb 4

    STRX deltas 8

    WITH t(col1,col2,col3) AS
            (
            select col1,col2,col3 from test_table
             union all
             select col1,col2,col3-1 from t where col3>1)
    SELECT *
      FROM t
      order by col1,col3;
    

    OUTPUT:

    COL1 COL2 COL3

    -------------------------

    str1 str2 1

    str1 str2 2

    strB Stra 1

    strA, strb 2

    strA, strb 3

    strA, strb 4

    deltas STRX 1

    STRX deltas 2

    deltas STRX 3

    STRX deltas 4

    STRX deltas 5

    STRX deltas 6

    STRX deltas 7

    STRX deltas 8

    See you soon,.

    Manik.

  • grouping of several lines into one line

    Totally, I need help with this easy... Basically, I have several lines for a unique userid that I need to be grouped into a single line.

    Here's what I have before:

    USER ID MONTH1_SEVERITY MONTH2_SEVERITY MONTH3_SEVERITY

    MODERATE 1900055
    1900055 <... it'sa just space... > MODERATE
    1900055 <... it'sa just space... > MODERATE


    What I wish to see:
    USER_ID MONTH1_SEVERITY MONTH2_SEVERITY MONTH3_SEVERITY

    MODERATE MODERATE MODERATE 1900055


    Thanks in advance.

    Rotate the data

    Select user_id,
    Max (month_1_severity),
    Max (month_2_severity),
    Max (month_3_severity)
    from table_name
    Group of user_id

  • Help: several lines subquery

    Hello

    My question hinges off the coast of the same type of DB as the question here a little backward (https://forums.oracle.com/thread/1982906).

    The question is: determine who or the authors wrote the books most often purchased by customers of JustLee books

    I'm currently building a subquery of several lines (I don't know if that would be the best way to approach). I have provided the table at the bottom of this post.

    By my code below, as you can see, this does not work for me. I'm going to pull the total number of each book (via isbn inside the authoridtable), then I'll look up the code of the author and, in the end, the name of the author (table orderitems then bookauthor). I work from the inside to the outside and can't get through using the first subquery.

    Could someone please be able to help point me in the right direction?

    Thanks for your help!

    SQL > SELECT isbn, authorid

    2 FROM bookauthor

    3. WHERE IN (SELECT COUNT (isbn) isbn

    4 FROM orderitems

    5 GROUP BY isbn)

    6 ORDER BY isbn, authorid;

    no selected line

    TABLES:

    SQL > select * from orderitems.

    ORDER ITEM # QUANTITY PAIDEACH ISBN NO.

    ---------- ---------- ---------- ---------- ----------

    1000 1 3437212490 1 19.95

    1001 1 9247381001 1 31.95

    1001 2 2491748320 1 85,45

    1002 1 8843172113 2 55.95

    1003 1 8843172113 1 55.95

    1003 2 1059831198 1 30.95

    1003 3 3437212490 1 19.95

    1004 1 2491748320 2 85,45

    1005 1 2147428890 1 39.95

    1006 1 9959789321 1 54.5

    1007 1 3957136468 3 72.15

    1007 2 9959789321 1 54.5

    1007 3 8117949391 1 8.95

    1007 4 8843172113 1 55.95

    1008 1 3437212490 2 19.95

    1009 1 3437212490 1 19.95

    1009 2 0401140733 1 22

    1010 1 8843172113 1 55.95

    1011 1 2491748320 1 85,45

    1012 1 8117949391 1 8.95

    1012 2 1915762492 2 25

    1012 3 2491748320 1 85,45

    1012 4 0401140733 1 22

    1013 1 8843172113 1 55.95

    1014 1 0401140733 2 22

    1015 1 3437212490 1 19.95

    1016 1 2491748320 1 85,45

    1017 1 8117949391 2 8.95

    1018 1 3437212490 1 19.95

    1018 2 8843172113 1 55.95

    1019 1 0401140733 1 22

    1020 1 3437212490 1 19.95

    SQL > select * from bookauthor;

    ISBN AUTH

    ---------- ----

    0132149871 S100

    0299282519 S100

    0401140733 J100

    1059831198 P100

    1059831198 S100

    1915762492 W100

    1915762492 W105

    2147428890 W105

    2491748320 B100

    2491748320 F100

    2491748320 R100

    3437212490 B100

    3957136468 A100

    4981341710 K100

    8117949391 R100

    8843172113 A100

    A105 8843172113

    8843172113 P105

    9247381001 W100

    9959789321 J100

    20 selected lines.

    SQL > select * from the author.

    FNAME LNAME AUTH

    ---- ---------- ----------

    S100 SAM SMITH

    J100 JANICE JONES

    A100 AUSTIN JAMES

    M100 SHEILA MARTINEZ

    K100 KZOCHSKY TAMARA

    P100 PORTER LISA

    A105 ADAMS JUAN

    B100 JACK BAKER

    P105 PETERSON TINA

    W100 WILLIAM WHITE

    W105 LISA WHITE

    R100 ROBINSON ROBERT

    F100 FIELDS OSCAR

    W110 WILKINSON ANTHONY

    14 selected lines.

    Hello

    Thanks for posting the sample data.

    Be sure to post the results desired from this data, the reason why you want to these results and your version of Oracle.

    You can reach the author table in the main query I posted earlier.

    WITH got_total AS

    (

    SELECT isbn

    The AMOUNT (quantity) AS total - may be

    , EVALUATE () OVER (ORDER OF SUM (amount) DESC) AS rnk

    Of orderitems

    GROUP BY isbn

    )

    SELECT b.isbn

    a.authorid

    a.lname

    a.fname

    t.total

    OF bookauthor b

    JOIN got_total t WE b.isbn = t.isbn

    JOIN the author an a.authorid ON = b.authorid

    WHERE t.rnk = 1

    ;

    I see that orderitems has a quantity column.  SUM (quantity), not to COUNT (*), is probably what you want to determine the author of bestsellers.

    The above query gives these results:

    TOTAL FNAME LNAME ISBN AUTH

    ---------- ---- ---------- ---------- ----------

    3437212490 B100 BAKER JACK 8

  • 01427 00000 - "einreihig subquery returns several lines.

    Hi all
    How can I solve it
    SELECT 
           v.code
          ,v.bar_code
          ,v.arb_name
          ,v.eng_name
          ,v.branch_no
          ,(SELECT sum(quantity) FROM viw_whs_items_movement GROUP BY branch_no)
    FROM  viw_whs_items_movement V
    This code gives me this error
    01427 00000 - "einreihig subquery returns several lines.
    I know that I have more value, but I need this value

    Result group
    SELECT sum(v.quantity) 
    FROM viw_whs_items_movement v 
    GROUP BY v.branch_no
    ##########################
    SUM(V.QUANTITY)
    ---------------
             114453 
               2501 
               8137 
              13270 
              15230 
             120626 
              22536 
               2926 
              12848 
              37509 
              20911 
               7503 
               6248 
              17221 
                462 
                 24 
              15041 
              10307 
              12524 
             526627 
              10564 
               8230 
              13204 
               2840 
              80769 
            1418238 
             215694 
              15238 
               5063 
             104187 
                913 
             147079 
              11293 
              12678 
              18855 
    
     35 rows selected 

    Must be scalar subqueries. You demonstrate your subquery returns more than one line. Where the error.

    A solution would be to establish a correlation between the results of the subquery by joining the branch_id with branch_id of the outer query. However, as the two queries use the same table, you can simply use an analytical SUM():

    SELECT
           v.code
          ,v.bar_code
          ,v.arb_name
          ,v.eng_name
          ,v.branch_no
          ,sum(quantity) over (partition by branch_no) as branch_tot
    FROM  viw_whs_items_movement V      
    

    Cheers, APC

  • Get several lines with the request - please help

    Hello

    I have query that gives me the output below.
    select distinct a.*,cu1.usr_key,cu1.first_nm,cu1.last_nm
    from(
          select ng.grp_key, ng.grp_nm , gt.grp_typ_nm, stts.nm as grp_sts, ng.expiry_date, ng.updt_dttm, stts.stts_key
          from new_group ng, user_group ug, group_type gt, status stts
          where ug.grp_key = ng.grp_key and ng.grp_typ_key = gt.grp_typ_key and 
          ng.stts_key = stts.stts_key and
          ug.usr_grp_rl_typ_key = 1 and 
          lower(ng.grp_nm) like 'test foe%'
          union 
          select ng.grp_key, ng.grp_nm , gt.grp_typ_nm, sts.nm as grp_sts, ng.expiry_date, ng.updt_dttm, sts.stts_key
          from new_group ng, group_type gt, status sts
          where ng.grp_typ_key = gt.grp_typ_key and ng.stts_key = sts.stts_key and 
          lower(ng.grp_nm) like 'test foe%')a, common_user cu1, user_group ug1
    where cu1.stts_key = a.stts_key and cu1.usr_key = ug1.usr_key and ug1.usr_grp_rl_typ_key = 1 and ug1.grp_key(+) = a.grp_key;
    18345 enemy test remove Group organization DELETED February 9, 12 AM 3 09.38.34 29742 Sam Saed
    18345 enemy test remove Group organization DELETED 9 February 12 09.38.34 AM 3 29643 dummyName514 dummy
    18345 enemy test remove Group organization DELETED February 9, 12 09.38.34 AM 3 28917 TestMObileUser Gujral
    18345 enemy test remove Group organization DELETED February 9, 12 AM 3 27284 Rocky jegou 09.38.34
    18345 enemy test remove Group organization DELETED February 9, 12 AM 3 28920 Bhavani Gujral 09.38.34
    18345 enemy test remove Group organization DELETED 9 February 12 09.38.34 AM 3 29645 dummyFName516 dummy
    18345 enemy test remove Group organization DELETED February 9, 12 AM 3 27316 Karthik Gilani 09.38.34
    18345 enemy test remove Group organization DELETED February 9, 12 AM 3 28147 Bowl David Mathews 09.38.34
    18345 enemy test remove Group organization DELETED February 9, 12 AM 3 09.38.34 29731 Sam Saed
    18345 enemy test remove Group organization DELETED February 9, 12 AM 3 28919 Madhu mango 09.38.34

    For a group 18345, there are 10 users and this is the reason why I get a multiple user records.

    I can't avoid these last three columns, because I have to show these values in the application.

    In my opinion, the UNION is at the origin of the problem. Can I replace the UNION here? Please share your ideas on this.

    Thank you
    Rambeau

    Published by: ouali on February 9, 2012 22:35

    Hello

    because I have to show these values in the application.

    What is your problem then? If you simply issue a SELECT statement to application code or send the data back to REF CURSOR, it will be quite OK to have several lines. That's what the SELECT statements are for: to return sets of results with several lines.
    So, could not explain your problem more in detail please? If you get an error somewhere, provide the code causing the error and the error message (it is probably ORA-001422 exact extraction returns several lines somewhere in PL: / SQL, isn't it? then post here).

    In my opinion, the UNION is at the origin of the problem. Can I replace the UNION here? Please share your ideas on this.

    Us don't know not the answer to this question, because no one here knows your needs (what you need).

  • Report to concatenate several lines into one line

    I have three tables:
    1 project Pk = proj_id
    2 Resources_on_Project Pk = Resources_on_proj_id Foreign_key = proj_id
    3 cost Pk = cost_id Foreign_key = proj_id

    columns in the table:

    Project: proj_id, proj_name, proj_description
    Resources_on_Project: Resources_on_proj_id, proj_id, id_ressource
    cost: cost_id, proj_id, cost_type, cost_incurred

    the table relationships:

    Project: Resources_on_project 1:m (project has several resources in Appendix)
    Cost of the project: 1:m (project has many costs in annex)

    Data:

    Project:
    PROJ_ID, proj_name, proj_description
    1, CDM, Advisory Services

    2, efficient lighting, efficient ESCO

    Resources_on_project
    Resources_on_proj_id, proj_id, id_ressource
    1, 1, 1
    2, 1, 2
    3, 2, 3
    4, 2, 4

    Cost:
    cost_id proj_id cost_type cost_incurred
    1.1, food, 1200
    2.1, travel, 2000
    3.1, trip, 3500
    4.1 food, 1200
    5.1, trip, 1400
    6.1, travel, 1200
    7,2 trip, 2000
    8.2 food, 1200
    9.2, trip, 1300
    10.2, food, 2000
    11.2, travel, 800
    12.2, travel, 1150
    13.2, food, 3000
    14.2, food, 1000
    15.2, food, 2400


    First project has 2 resources attached to it and 6 different costs.
    Second project includes 2 resources and 9 heads of different costs.

    I want a report that gives me:

    Proj_name, Proj_description, id_ressource, cost_incurred
    Advisory services CDM 10500 1/2

    ESCO effective effective lighting 14850 3/4


    I wrote a query:
    «Select «PROJECT»» PROJ_NAME' as 'PROJ_NAME. "
    ««PROJECT»» PROJ_DESCRIPTION' as 'PROJ_DESCRIPTION. "
    sum (COST. COST_INCURRED) as "COST_INCURRED."
    'RESOURCES_ON_PROJECTS '. "" RESOURCE_ID ' as 'RESOURCE_ID.
    'COST', 'cost ',.
    "RESOURCES_ON_PROJECTS" "RESOURCES_ON_PROJECTS"
    'PROJECT' 'PROJECT '.
    where "PROJECT. "" PROJ_ID "=" RESOURCES_ON_PROJECTS. " "" PROJ_ID.
    and 'PROJECT '. "" "PROJ_ID '=' COST. PROJ_ID.
    PROJECT group. PROJ_NAME, PROJECT. PROJ_DESCRIPTION, RESOURCES_ON_PROJECTS. ACCOUNTABLE_RESOURCE_ID

    the result is:

    Advisory services CDM 1 10500
    Advisory services CDM 2 10500
    ESCO effective effective lighting 3 14850
    ESCO effective effective lighting 4 14850

    It gives a new line for each different resource.


    I want to:
    Advisory services CDM 10500 1/2
    ESCO effective effective lighting 14850 3/4

    any help will be appreciated.

    Published by: Rahul Gupta on September 7, 2009 16:07

    Rahul Gupta says:
    Shadow of Blu,

    It's exactly what I wanted. But the measures specified by you are not clear for me.

    can you let me know how I can implement?

    Okay... Let's take the internal selection...

    SQL> select proj_name
      2        ,proj_desc
      3        ,resource_id
      4        ,cost
      5        ,row_number() over (partition by proj_name order by resource_id) as rn
      6  from output
      7  /
    
    PROJ_NAME PROJ_DESC               RESOURCE_ID       COST         RN
    --------- ----------------------- ----------- ---------- ----------
    CDM       Advisory Services                 1      10500          1
    CDM       Advisory Services                 2      10500          2
    Efficient ESCO Efficient lighting           3      14850          1
    Efficient ESCO Efficient lighting           4      14850          2
    
    SQL>
    

    This affects a line number for each line, each group proj_name (partition). Line numbers are allocated in the order of the id_ressource.

    Now, using a (hierarchical) query connection we create a hierarchy of folders as well as RN = 2 is considered to be a child of RN = 1, etc..

    SQL> ed
    Wrote file afiedt.buf
    
      1  select level
      2        ,lpad(' ',(level-1)*2,' ')||x.proj_name as proj_name -- indent for hierarchical illustration only
      3        ,x.proj_desc
      4        ,x.resource_id
      5        ,x.cost
      6        ,x.rn
      7  from (
      8        select proj_name
      9              ,proj_desc
     10              ,resource_id
     11              ,cost
     12              ,row_number() over (partition by proj_name order by resource_id) as rn
     13        from output
     14       ) x
     15  connect by proj_name = prior proj_name and rn = prior rn + 1
     16* start with rn = 1
    SQL> /
    
         LEVEL PROJ_NAME       PROJ_DESC               RESOURCE_ID       COST         RN
    ---------- --------------- ----------------------- ----------- ---------- ----------
             1 CDM             Advisory Services                 1      10500          1
             2   CDM           Advisory Services                 2      10500          2
             1 Efficient       ESCO Efficient lighting           3      14850          1
             2   Efficient     ESCO Efficient lighting           4      14850          2
    
    SQL>
    

    Now, using the sys_connect_by_path function we can get it to collect the data, because it passes through to the bottom of the hierarchy...

    SQL> ed
    Wrote file afiedt.buf
    
      1  select level
      2        ,lpad(' ',(level-1)*2,' ')||x.proj_name as proj_name
      3        ,x.proj_desc
      4        ,x.resource_id
      5        ,sys_connect_by_path(resource_id,'/') as resources
      6        ,x.cost
      7        ,x.rn
      8  from (
      9        select proj_name
     10              ,proj_desc
     11              ,resource_id
     12              ,cost
     13              ,row_number() over (partition by proj_name order by resource_id) as rn
     14        from output
     15       ) x
     16  connect by proj_name = prior proj_name and rn = prior rn + 1
     17* start with rn = 1
    SQL> /
    
         LEVEL PROJ_NAME       PROJ_DESC               RESOURCE_ID RESOURCES        COST         RN
    ---------- --------------- ----------------------- ----------- ---------- ---------- ----------
             1 CDM             Advisory Services                 1 /1              10500          1
             2   CDM           Advisory Services                 2 /1/2            10500          2
             1 Efficient       ESCO Efficient lighting           3 /3              14850          1
             2   Efficient     ESCO Efficient lighting           4 /3/4            14850          2
    
    SQL>
    

    Now, we can store up to the sys_connect_by_path to eliminate the left "/" simply by using the TRIM function.
    We also need to do however is to choose only the lines that have reached the bottom of the hierarchy (the nodes). We have a pseudo-device column we can refer to called CONNECT_BY_ISLEAF...

    SQL> ed
    Wrote file afiedt.buf
    
      1  select level
      2        ,lpad(' ',(level-1)*2,' ')||x.proj_name as proj_name
      3        ,x.proj_desc
      4        ,x.resource_id
      5        ,ltrim(sys_connect_by_path(resource_id,'/'),'/') as resources
      6        ,x.cost
      7        ,x.rn
      8        ,connect_by_isleaf
      9  from (
     10        select proj_name
     11              ,proj_desc
     12              ,resource_id
     13              ,cost
     14              ,row_number() over (partition by proj_name order by resource_id) as rn
     15        from output
     16       ) x
     17  connect by proj_name = prior proj_name and rn = prior rn + 1
     18* start with rn = 1
    SQL> /
    
         LEVEL PROJ_NAME       PROJ_DESC               RESOURCE_ID RESOURCES        COST         RN CONNECT_BY_ISLEAF
    ---------- --------------- ----------------------- ----------- ---------- ---------- ---------- -----------------
             1 CDM             Advisory Services                 1 1               10500          1             0
             2   CDM           Advisory Services                 2 1/2             10500          2             1
             1 Efficient       ESCO Efficient lighting           3 3               14850          1             0
             2   Efficient     ESCO Efficient lighting           4 3/4             14850          2             1
    
    SQL>
    

    So now we can filter only the lines where CONNECT_BY_ISLEAF = 1, also remove the output columns and calculates values etc, we don't need to see.

    SQL> ed
    Wrote file afiedt.buf
    
      1  select x.proj_name
      2        ,x.proj_desc
      3        ,ltrim(sys_connect_by_path(resource_id,'/'),'/') as resources
      4        ,x.cost
      5  from (
      6        select proj_name
      7              ,proj_desc
      8              ,resource_id
      9              ,cost
     10              ,row_number() over (partition by proj_name order by resource_id) as rn
     11        from output
     12       ) x
     13  where connect_by_isleaf = 1
     14  connect by proj_name = prior proj_name and rn = prior rn + 1
     15* start with rn = 1
    SQL> /
    
    PROJ_NAME       PROJ_DESC               RESOURCES        COST
    --------------- ----------------------- ---------- ----------
    CDM             Advisory Services       1/2             10500
    Efficient       ESCO Efficient lighting 3/4             14850
    
  • deleting several lines in a report?

    db11gxe, apex 4.0, firefox 24,

    How to delete several lines in a report at the same time?

    Thank you

    Hi newbi_egy,

    Here's a demo with a few steps that can be used in your scenario-

    (1) this is the query for a report on the emp table that has column empno with values single-

    SELECT APEX_ITEM.CHECKBOX(1,empno) " ", ename, job FROM   emp ORDER  by 1
    

    (2) a button Delete is created that submits the page.

    (3) a sur-soumettre the process is created with point process on submit - after calculations and Validations to determine that the sub process is running when you click the button remove.

    BEGIN
    FOR i in 1..APEX_APPLICATION.G_F01.count
    LOOP
    delete from emp where empno=APEX_APPLICATION.G_F01(i);
    END LOOP;
    END;
    

    I hope this could help you.

    Kind regards

    Das123

  • How do I rotate my result of a query from a line to a SQL column?

    Hey, guys:

    Is it possible that I can rotate my result of a query from a line to a SQL column?

    It's a certain type of pivot example
    Instead of
    DEPTNO DNAME
    -------- ---------------
    10 accounting
    It would be
    DEPTNO: 10
    DNOM: ACCOUNTING

    Hello

    When you have N columns to rank 1 and you want to display in the form of 1 column on several lines, it's called Unpivoting . Here's a way to do it:

    WITH     cntr     AS
    (
         SELECT     LEVEL     AS n
         FROM     dual
         CONNECT BY     LEVEL <= 2     -- number of columns to be unpivoted
    )
    SELECT     CASE c.n
             WHEN  1  THEN  'DEPTNO'
             WHEN  2  THEN  'DNAME'
         END || ':'        AS label
    ,     CASE c.n
             WHEN  1  THEN  TO_CHAR (d.deptno)
             WHEN  2  THEN  d.dname
         END || ':'        AS val
    ,     d.deptno               -- PK, if needed
    FROM         cntr        c
    CROSS JOIN  scott.dept  d
    WHERE   deptno = 10               -- or whatever
    ;
    

    The query above works in Oracle 9.1 or more.
    From Oracle 11.1, you can also use the SELECT... Function of the UNPIVOT operator.

  • Several lines of subquery

    Newbie needs help.

    My SQL statement returns multiple lines, but even after reading the manual I can't understand yet how to use the IN, ALL or PART of the operators to make several lines.

    Version:

    BANNER

    Oracle Database 10 g Express Edition Release 10.2.0.1.0 - product

    PL/SQL Release 10.2.0.1.0 - Production

    CORE 10.2.0.1.0 Production

    AMT for 32-bit Windows: Version 10.2.0.1.0 - Production

    NLSRTL Version 10.2.0.1.0 - Production

    Update proj_assigned
    Set project_cost = (select job_charge_per_hour * proj_assigned hours_allocated);

    RESULT: einreihig subquery returns multiple rows

    Edited by: 996465 03/28/2013 10:47

    Update proj_assigned
    Set project_cost = (select job_charge_per_hour * proj_assigned hours_allocated);

    In the above sub query you select all lines. Use where clause so that it chooses the only record in the subquery.

    Or

    You can modify the query, if you want to update project_cost in the Proj_assigned table as below

    Update proj_assigned set project_cost = job_charge_per_hour * hours_allocated;

  • Update of several lines using the join condition

    Hi all

    CREATE OR REPLACE
    PROCEDURE update_t
    IS

    BEGIN
    SheikYerbouti IN (SELECT EMPLOYEE_ID, FIRST_NAME, LAST_NAME FROM hr.employees)
    LOOP
    UPDATE
    HR.employees1
    SET
    FOCA =)
    Select concat (FIRST_NAME, LAST_NAME) in the hr.employees where SheikYerbouti. EMPLOYEE_ID = 197);
    END LOOP;
    END update_t;
    /

    I'm trying to update column Foca Employees1 table. When I run this procedure, I get the error

    Error report:
    ORA-01427: einreihig subquery returns multiple rows
    ORA-06512: at "SYSTEM. UPDATE_T", line 13
    ORA-06512: at line 1
    01427 00000 - "einreihig subquery returns several lines.

    Please let me know a solution for this.

    Thank you
    Mathon

    Hello Mathieu,
    in your internal SQL result set is not limited to just one line.
    Try this

    UPDATE hr.employees1 SET
    FIRST_LAST= (select concat(FIRST_NAME,LAST_NAME) from hr.employees where emp_rec.EMPLOYEE_ID=hr.employees.employee_id);
    

    Your version had no restrictions on selected lines of hr.employees. You gave a where condition clause that is not related to the query.

    The best solution for your problem is to avoid completely any PL/SQL loop. You can try something like this:

    update
       (select
           e1.first_last,
           e.first_name,
           e.last_name
        from
           hr.employees1 e1,
           hr.employees e
        where
           e1.employee_id=e.employee_id) set
       first_last=first_name||last_name;
    

    But beware, the updates on the joints work only under certain restrictions. The key of the table to be updated must be the join key. (key preserved is the word to look for).

    Hope that helps,
    dhalek

  • Insert several lines with dynamic data

    Hello
    When I do an insert into a table that has several lines of dynamic information. on
    a page, it inserts all rows that are dynamically filled. I want only what he
    to insert the lines that I choose the initials on. How can I do? Let's say I
    have 5 items that are displayed on a page and I want to insert only original
    the first 2 because the last 3 are left blank, how should I do this? I tried
    implementation of an if statement that says:

    < cfif "form. "Help of # PNR_Approval_Initials #" NEQ "" > "".

    Then make the insertion in the table

    < cfelse >
    < / cfif >

    I have this game were also up in a loop that says:

    < cfloop index = "help" list = "" #form.listofids # "delimiters =",">"

    Here is the code for just the insertion. I also have a code here
    Update another table. I got this to work, so I just try to get the insertion
    works fine for the moment. I can not use this where the query statement:
    Where ItemID = #id # because I'm trying to insert into the table of approval, not
    the items table. The table is just updated with some other info. in
    a few other input boxes.

    < cfloop index = "help" list = "" #form.listofids # "delimiters =",">"
    < cfif "form. "Help of # PNR_Approval_Initials #" NEQ "" > "".

    < cfquery Datasource = '#application. DataSource #">"
    Insert into accreditation (APV_ItemID,
    APV_ECID,
    Document_Type,
    Approval_Initials)

    Values (' #Evaluate ("form.) (' ItemID # help # ") #',
    ' #Evaluate ("form. ("ECID # help #") #',
    < cfif isDefined (form '. ') ("Help of # PNR_Doc_Type # ') and
    "form. "Help of # PNR_Doc_Type #" NEQ "" > "".
    ' #Evaluate ("form. ("Help of # PNR_Doc_Type # ') #',
    < cfelse >
    NULL,
    < / cfif >

    < cfif isDefined (form '. ') ("Help of # PNR_Approval_Initials # ') and
    "form. "Help of # PNR_Approval_Initials #" NEQ "" > "".
    ' #Evaluate ("form. (Aide de # PNR_Approval_Initials #») #
    < cfelse >
    Null value
    (< / cfif >)

    < / cfquery >

    < / cfif >
    < / cfloop >

    On the page display, just a table of dynamic info. Here are the 4
    things that I have on this page that needs to be inserted to the database.

    < input type = "hidden" name = "' ECID #ItemID #" value = "#ECID #" > "
    < input type = "hidden" name = "' ItemID #ItemID #" value = "#ItemID #" > "
    < input type = "hidden" name = "" PNR_Doc_Type #ItemID # ' value = "PNR Req" > "

    < td align = "center" >
    < cfif Approval_Initials is not "" > "".
    #Approval_Initials #.
    < cfelse >

    < select name = "PNR_Approval_Initials #ItemID #" >
    < option value = "" > select initials < / option >
    < cfloop query = "ShowInitials" >
    < Cfif Engineer_Initials EQ 1 >
    < option value = "#Initials #" > #Initials # < / option >
    < / cfif >
    < / cfloop >
    < / select >

    < / cfif >
    < table >

    Can someone help me please on just the insertion in the database so that it
    will insert on the lines that I chose the initials on and not others? Thank you.

    Andy

    You almost managed, but I see that you have commented.

    (" The help of # PNR_Approval_Initials # ') AND form ["PNR_Approval_Initials # help #" ""] NEQ "" >

    Do things here

  • Using pathfinder to cut a shape of several lines

    Hello

    There is probably a really easy answer to this, but I'm not. I created a model space "scratches" by using several lines aligned and equal remote etc, I then placed a form of rectangle on top of these lines and to extract the rectangle of the lines so that I'm only left with the pattern of scratches in the area of the rectangle. Hope that makes sense, could not think of a better way to describe!

    Thank you

    I'm not sure that understand what you're trying to do, i.e. the need to use the Scout at all. What group the traits and resize or make a compound path? Or even by selecting copy/cut, then 'paste' in the new frame?

    You try to use it as a filling for a frame that is containsomething else? If so, you might want to build a gradient instead.

    Peter

  • Selection of several lines

    OK, I have three tables, two tables are one and one is one to many. From one to the other tables have all the data in a row and one of many data available in several lines. The table several (named county_notes) has notes on specific counties. Other tables (named county_bio and county_stats) have different information about each County. The three tables are connected by a code.

    What I want to be able to list notes on each county and County information in the same report.

    For example:

    Record1
    County: Craven
    Phone: (252)123-4567
    Notes:
    Judy is nice
    John is average

    The tables would be like this:

    county_bio
    County_name ID
    1 craven


    county_stats
    ID county_phone
    1 (252) 123-4567

    county_notes
    Notes ID
    1 Judy is nice
    1 John is average


    Of course the tables above are just examples, but you get the idea of how the tables are arranged to the top. The problem is that I can join the table of county_notes to one of the two using tables, it's bad. Problem 2, Coldfusion separates each note in another record. So I find myself with record "craven" showing twice (once with the note about judy) and once with the note about john.

    Here's the SQL code that connects county_bio and county_notes:
    SELECT *.
    OF county_bio
    County_notes LEFT JOIN
    ON county_bio.ID = county_notes.county_ID

    First of all how all three tables connected? And on the other hand how ColdFusion to print each note about the County in a record?

    Thanks for any help! I have worked on this for a few days and am running out of ideas.

    wbnc1902 wrote:
    > First of all how all three tables connected?

    something like this:

    SELECT *.
    OF (county_bio INNER JOIN county_stats ON cb.ID = cs.ID cs cb)
    LEFT JOIN county_notes ON cb.ID = cn.county_ID cn

    NOTE: it is not the best practice use SELECT *. Instead, you should
    List the actual columns that you have selected.

    > And on the other, how do
    > ColdFusion to print each note about the County in a record?

    Search for the tag CFOUTPUT GROUP attribute in the docs

    HTH

    ---
    Azadi Saryev
    SABAI - Dee.com
    http://www.SABAI-Dee.com

  • How can I get rid of "warning: query exceeded 200 lines..." message

    Hello

    I have a custom page to question the details of our inventory. I show 100 lines on the page. I noticed today I can hit him then once and then I get the message "query exceeded 200 lines. Potentially more rows exist, please limit your query "." If I try to export this data using an export to Excel button, it gives me the message "there are no data to export.

    I am VERY new to OAF... y at - it a property or something somewhere that I can change to fix this? We will have potentially 100s of thousands of records to view and export, so 200 is simply not acceptable.

    We are on ATG RUP7 11.5.10.2. It is a fully customized page, pulling of custom tables. Please let me know if any other information is needed.

    Thank you
    Janel

    You need to reset the option profile ' FND: view object Fetch Size Max "of 200 (default) to the value that you think fits your needs.

    Please note that the definition of a very high value for this profile can impact performance, and I recommend you test first before deploying on production.

    Thank you
    Shailendra

Maybe you are looking for