Consolidation of three lines into one

Hello

I am struggling to understand this and my Google search didn't quite led me to what I need. I found a few ideas like sys_connect_by_path but I want to convert my three rows of columns (using a line), not concatenate them. I can't quite find the right thing or get out. The code below gives me the columns I want but I can't understand how it together on a single line. When I Uncomment the line group he doesn't like it because the fields role and emp are not group expressions. I want to rotate values strings and not numbers (role).

Everyone would be kind enough to help? my brain froze! : D

Thank you very much

Jon
With t As

        (

         Select 25840 id, 'Bob' emp, 'Primary' role  From dual Union All

         Select 25840, 'Jim', 'Secondary' From dual Union All

         Select 25840, 'Dave', 'Tertiary' From dual

        )

    Select 
    
    id
    ,decode(role,'Primary',emp) Prim
    ,decode(role,'Secondary',emp) Sec
    ,decode(role,'Tertiary',emp) Ter

    From
    
    t

    --group by id

You were close to:

With t as (
Select 25840 id, 'Bob' emp, 'Primary' role  From dual Union All
Select 25840, 'Jim', 'Secondary' From dual Union All
Select 25840, 'Dave', 'Tertiary' From dual
)
select id
,      max(decode(role,'Primary',emp)) Prim
,      max(decode(role,'Secondary',emp)) Sec
,      max(decode(role,'Tertiary',emp)) Ter
from   t
group by id

Tags: Database

Similar Questions

  • Add line button adds three lines (not one)

    In the report of Dropbox form - UNIFORM - (04) .pdf there are two tables. The two tables have a single button "add a line". In the table at the top of the page, click it once actually adds three lines (not one, as it should be). In the second table, it works as it should (by adding only one line). However, for the life of me, I can't understand why.

    The upper table using this code:

    Form1. #subform [0]. SUB_of_Table1.Table1.HeaderRow.Subform3.AddButton::click - (JavaScript, client)

    Table1._Row1.addInstance (true);

    The bottom table using this code:

    Form1. #subform [0]. SUB_of_Table2.table2.HeaderRow.Subform2.AddButton::click - (JavaScript, client)

    Table2._Row1.addInstance (true);

    Except for a form of corruption of document, I can't begin to guess why the top adds three lines, but inside only one. It drives me crazy.

    No, it doesn't always work does not, try to use Gmail drive share or send me a private message and I'll give you my email.

  • Fusion of the 2 lines into one

    Greedings,

    I have the following output
            
    1       A       null     null
    
    2      null      B         C
    How is it possible to merge in one line?
    CREATE TABLE test_g 
    (
    a VARCHAR2(1),
    b VARCHAR2(1),
    c VARCHAR2(1)
    )
    INSERT INTO test_g 
    VALUES (null,'B','C');
    
    INSERT INTO test_g 
    VALUES ('A',null,null);

    You could do this:

    SELECT MAX(a),
           MAX(b),
           MAX(c)
    FROM   test_g
    
  • Combine multiple lines into one line (from two tables / result sets)

    Hello experts,

    I would like to know how to combine multiple lines/records in a single record. Here are the DDL and DML to tables:

    create table test_table)

    client_name varchar2 (50 char),

    login_time timestamp (6).

    logout_time timestamp (6).

    auto_type varchar2 (10 char)

    )

    create table root_table)

    navigation_time timestamp (6).

    client_name varchar2 (50 char),

    VARCHAR2 (50 char) nom_du_groupe

    )

    Insert into test_table

    values ("John", TO_TIMESTAMP ('2013-12-05 17:04:01.512 ',' YYYY-MM-DD HH24:MI:SS.)) FF'), TO_TIMESTAMP ('2013-12-05 17:27:31.308 ',' YYYY-MM-DD HH24:MI:SS.) FF'), 'SIMPLE');

    Insert into test_table

    values ('David', TO_TIMESTAMP ('2013-12-05 06:33:01.308 ',' YYYY-MM-DD HH24:MI:SS.)) FF'), TO_TIMESTAMP ('2013-12-05 06:45:01.112 ',' YYYY-MM-DD HH24:MI:SS.) FF'), 'SIMPLE');

    insert into root_table

    values (TO_TIMESTAMP ('2013-12-05 17:04:01.512 ',' YYYY-MM-DD HH24:MI:SS.)) FF'), 'John', "invalid");

    insert into root_table

    values (TO_TIMESTAMP ('2013-12-05 17:14:22.333 ',' YYYY-MM-DD HH24:MI:SS.)) FF'), 'John', "GROUP_1");

    insert into root_table

    values (TO_TIMESTAMP ('2013-12-05 17:27:31.308 ',' YYYY-MM-DD HH24:MI:SS.)) FF'), 'John', "GROUP_1");

    insert into root_table

    values (TO_TIMESTAMP ('2013-12-05 06:33:01.308 ',' YYYY-MM-DD HH24:MI:SS.)) FF'), "David", "invalid");

    insert into root_table

    values (TO_TIMESTAMP ('2013-12-05 06:45:01.112 ',' YYYY-MM-DD HH24:MI:SS.)) FF'), 'David', 'GROUP_5');

    game results test_table

    client_name

    login_time logout_time auto_typeJohn05/12/2013 5:04:01.512000 PM05/12/2013 5:27:31.308000 PMSIMPLEDavid05/12/2013 6:33:01.308000 AM05/12/2013 6:45:01.112000 AMSIMPLE

    root_table result set

    navigation_time client_name GroupName
    05/12/2013 5:04:01.512000 PMJohnNot valid
    05/12/2013 5:14:22.333000 PMJohnGROUP_1
    05/12/2013 5:27:31.308000 PMJohnGROUP_1
    05/12/2013 6:33:01.308000 AMDavidNot valid
    05/12/2013 6:45:01.112000 AMDavidGROUP_5

    And here is the SQL code I'm writing:

    Select a.customer_name, a.login_time, a.logout_time, a.auto_type, Max (b.group_name)

    from test_table a, b root_table

    where a.customer_name = b.customer_name

    Group of a.customer_name, a.login_time, a.logout_time, a.auto_type

    As the 'invalid' value is greater than the value "GROUP_1" (based on the number of letter in English), the GroupName is returned as 'invalid '. I want to bring the GroupName based on the navigation_time column in the root_table so that it always returns a valid GroupName. Please help me.

    Output current:

    Client_name.      Login_Time.     Logout_Time |     Auto_Type |     GroupName

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

    John |     05/12/2013 5:04:01.512000 PM |     05/12/2013 5:27:31.308000 PM |     SIMPLE |     Not valid

    David |     05/12/2013 6:33:01.308000 AM |     05/12/2013 6:45:01.112000 AM |     SIMPLE |     Not valid

    Expected results:

    Client_name.      Login_Time.     Logout_Time |     Auto_Type |     GroupName

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

    John |     05/12/2013 5:04:01.512000 PM |     05/12/2013 5:27:31.308000 PM |     SIMPLE |     GROUP_1

    David |     05/12/2013 6:33:01.308000 AM |     05/12/2013 6:45:01.112000 AM |     SIMPLE |     GROUP_5

    Thank you!

    Adding INSERT statements, current and planned outputs.

    This...

    SELECT client_name

    login_time,

    logout_time,

    auto_type,

    GroupName

    Of

    (select a.customer_name,

    a.login_time,

    a.logout_time,

    a.auto_type,

    b.group_name,

    ROW_NUMBER() over (PARTITION BY a.customer_name, a.login_time, a.logout_time, a.auto_type ORDER BY b.group_name) rn

    from test_table a, b root_table

    where a.customer_name = b.customer_name)

    WHERE rn = 1;

    OUTPUT:-

    =========

    David DECEMBER 5, 13 06.33.01.308000000 AM DECEMBER 5, 13 06.45.01.112000000 AM SIMPLE GROUP_5
    John DECEMBER 5, 13 05.04.01.512000000 PM DECEMBER 5, 13 05.27.31.308000000 PM SIMPLE GROUP_1

    Thank you

    Ann

  • convert multiple lines into one

    Hi all

    We got lines with 'yes/no' ' yes/no' for available deposits and appropriations available:
    select 1 as client_id, 'yes' as credits, 'no'  as deposits, 'A' as division_name from dual union all 
    select 1 as client_id, 'no'  as credits, 'yes' as deposits, 'A' as division_name from dual union all 
    select 2 as client_id, 'yes' as credits, 'no'  as deposits, 'A' as division_name from dual union all 
    select 2 as client_id, 'no'  as credits, 'yes' as deposits, 'B' as division_name from dual
    My need is to show only one line for each client_id in a section. For example, client_id = 1 is 'Yes' for credits and deposits ' yes' in the same division, so it must be displayed in a line:
    select 1 as client_id, 'yes' as credits, 'yes'  as deposits, 'A' as division_name from dual union all 
    select 2 as client_id, 'yes' as credits, 'no'   as deposits, 'A' as division_name from dual union all 
    select 2 as client_id, 'no'  as credits, 'yes'  as deposits, 'B' as division_name from dual
    How can I make it?
    SQL> with t as
      2    (select 1 as client_id, 'yes' as credits, 'no'  as deposits, 'A' as division_name from dual union all
      3  select 1 as client_id, 'no'  as credits, 'yes' as deposits, 'A' as division_name from dual union all
      4  select 2 as client_id, 'yes' as credits, 'no'  as deposits, 'A' as division_name from dual union all
      5  select 2 as client_id, 'no'  as credits, 'yes' as deposits, 'B' as division_name from dual
      6    )
      7  select client_id, max(credits) credits, max(deposits) deposites, division_name
      8  from   t
      9  group by client_id, division_name;
    
     CLIENT_ID CRE DEP D
    __________ ___ ___ _
             1 yes yes A
             2 yes no  A
             2 no  yes B
    

    ?

  • combining the three queries into one

    Hello everyone, I have the following queries in a format similar to below and I would like to combine it with one... I know I could use an if statement but is it possible to do in pure sql
    select t.p1,
           t.p2,
           t.p3,
           t.p4
    from tbl_one t
    where t.p4 like (p4_parameter)
    order by t.p1
    
    select t.p1,
           t.p2,
           t.p3,
           t.p4
    from tbl_one t
    where upper(t.p1) like upper ((p1_parameter) || '%');
    
    select t.p1,
           t.p2,
           t.p3,
           t.p4
    from tbl_one t
    where t.p1 != 0;

    combine all three queries with GOLD seats...

    select t.p1,
           t.p2,
           t.p3,
           t.p4
    from tbl_one t
    where t.p4 like (p4_parameter)
    and upper(t.p1) like upper ((p1_parameter) || '%')
    and t.p1 != 0;
    

    and as suggested madhu, while displaying u should take care of type of data as well...

    If you want to compare t.p1! = 0
    you need to replace

    t.P1! = 0 to t.p1! = '0'

    or if you want
    t.P1! = 0 compared to not null
    the

    t.P1 is not null

    Concerning

    UMI

  • Representing data of several lines into one line

    Hi all

    Please check the query below:
    select manager_id mg_id, employee_id emp_id, last_name name from employees 
    where manager_id = '100'
    and DEPARTMENT_ID = '80'
    If I run the following query, o/p then comes wise line; as below:
           mg_id           emp_id            name
           100             145                     Russell
           100             146                     Partners
           100             147                     Errazuriz
           100             148                     Cambrault
           100             149                     Zlotkey
    But if I want the o/p as below; That is to say; under Manager # 100, all employees emp_id and name should come in ONE row NOT in several lines:
    mg_id                   emp_id     name          emp_id       name       emp_id     name         emp_id     name                emp_id         name
    100                             145             Russell     146       Partners        147     Errazuriz       148              Cambrault        149        Zlotkey
    pls help me sort the above desired o/p.

    kindly tell me if there are guidelines of accounting (except 'Plain Text help' on the right side) in this forum. I tried a lot of post above 2 o/p in easy to read format, but could not do so.

    Published by: Francis Sep 20, 2009 04:28

    Published by: Francis Sep 20, 2009 04:29
  • 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
    
  • How to display/concatenate several lines into one line

    I have a report that retrieves a project name and its corresponding attached resources.
    If tha project has 4 resources attached will appear 4 different columns.
    is there a way to display a single line with the corresponding resources names concatenated into a single cell?

    There is a related issue of PL/SQL and is not a matter of apex. However, see this as an example:

    http://Apex.Oracle.com/pls/OTN/f?p=31517:84

    There are also a bunch of other code related to this issue.

    Denes Kubicek
    ------------------------------------------------------------------------------
    http://deneskubicek.blogspot.com/
    http://www.Opal-consulting.de/training
    http://Apex.Oracle.com/pls/OTN/f?p=31517:1
    ------------------------------------------------------------------------------

  • 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

  • Concatenate the strings of several lines into one line.

    Hello

    What is the name of this analytical function (or log in) which
    would return more line as a concatenated line strings. that is to say:
    (I know that it is possible using the regular functions of pipeline).
    ROW1:   STR1
    ROW2:   STR2
    ROW3:   STR3
    
    select tadah().... from ...
    
    result:
    
    ROW1: STR1 STR2 STR3
    Thank you.

    Hello

    DanielD wrote:
    Hello

    What is the name of this analytical function (or log in) which
    would return more line as a concatenated line strings. that is to say:
    (I know that it is possible using the regular functions of pipeline).

    ROW1:   STR1
    ROW2:   STR2
    ROW3:   STR3
    
    select tadah().... from ...
    
    result:
    
    ROW1: STR1 STR2 STR3
    

    The function is SYS_CONNECT_BY_PATH

  • Join the two lines into one game

    Hi all

    I have a table with 1 column and records are as below. Below I show only the first 4 records to give an idea.

    Select cn from CSGL_AD_GROUP_OP_COMP_MEM_TEMP where rownum < 5;

    CN
    -------------------------------------------------------------------------------
    CN = JZJXEEW00072305, OU = computers to office, OR = Secured_Systems, OR = Computers, OR = ZJX_ARTCC, OR
    = FL, OR = ESA, OU = ATO, OU = LOB, DC = faa, DC = gov
    CN = JI90NTW00069990, OU = computers to office, OR = Secured_Systems, OR = Computers, OR = I90_TRACO, OR
    = TX, OR = CSA, OU = ATO, OU = LOB, DC = faa, DC = gov

    Now, the requirement is to concatenate the 1st and 2nd rank, concat 3rd and 4th rank, conact 5th and 6th next row and so on and put it in a new column in the same table if its possible, if not in a new table.

    How can I do this, can someone help me.

    Thank you

    Hello

    There are numerous valid aproaches, may be the last of them is more effective than the other in some cases:

    select
     c1.key
    ,C1.cn||C2.cn cn
    from
    CSGL_AD_GROUP_OP_COMP_MEM2 C1,
    CSGL_AD_GROUP_OP_COMP_MEM2 C2
    where
    C1.key+1=C2.key
    and
    mod(c1.key,2)=1
    
    select key, cn from (
    SELECT
     cn || LEAD (cn) OVER (ORDER BY key) cn
    ,key
    FROM    CSGL_AD_GROUP_OP_COMP_MEM2
    )
    where
    mod(key,2)=1
    
    select key, cn from (
    select *
    from
    CSGL_AD_GROUP_OP_COMP_MEM2 C1
    model
    dimension by (key)
    measures (cn)
    rules(
    cn[any] order by key=cn[cv()]||cn[cv()+1]
    )
    )
    where
    mod(key,2)=1
    

    concerning

  • Combination of several lines into one

    Hello

    I have a table like this

    ID | name
    1 aWord
    1 Anotherword
    2 Gisela


    I would like a result of the query, where two rows (or a lot as it is in the table, with this id) to put in a string separated by commas, like this "aWord, Anotherword" ID = 1. Preferably, I would like to avoid using cursors...

    Any help on this is appreciated.

    Thank you

    /David N

    Like this...

    SQL> ed
    Wrote file afiedt.buf
    
      1  select deptno, ltrim(sys_connect_by_path(ename,','),',') as enames
      2  from (
      3        select deptno, ename, row_number() over (partition by deptno order by ename) rn from emp
      4       )
      5  where connect_by_isleaf = 1
      6  connect by deptno = prior deptno
      7         and rn = prior rn + 1
      8  start with rn = 1
      9* order by deptno
    SQL> /
    
        DEPTNO ENAMES
    ---------- --------------------------------------------------
            10 CLARK,KING,MILLER
            20 ADAMS,FORD,JONES,SCOTT,SMITH
            30 ALLEN,BLAKE,JAMES,MARTIN,TURNER,WARD
    
    Or to ensure names are distinct...
    
    SQL> ed
    Wrote file afiedt.buf
    
      1  select deptno, ltrim(sys_connect_by_path(ename,','),',') as enames
      2  from (
      3        select distinct deptno, ename, dense_rank() over (partition by deptno order by ename) rn
      4        from emp
      5       )
      6  where connect_by_isleaf = 1
      7  connect by deptno = prior deptno
      8         and rn = prior rn + 1
      9  start with rn = 1
     10* order by deptno
    SQL> /
    
        DEPTNO ENAMES
    ---------- --------------------------------------------------
            10 CLARK,KING,MILLER
            20 ADAMS,FORD,JONES,SCOTT,SMITH
            30 ALLEN,BLAKE,JAMES,MARTIN,TURNER,WARD
    
    SQL>
    
  • Divide a line into several points

    I see that I can use SDO_LRS. SPLIT_GEOM_SEGMENT to divide a line into one only point (and get 2 lines resulting).

    However, someone at - it an idea how can I split a line, at several points, in several segments? I need to do for the number of lines, so a function or procedure would be nice as appropriate.

    Thank you

    Published by: ronnie-m on April 22, 2013 04:43

    Sorry for pasting quick and dirty, was a minimum on time and problems with my dev env.

    Perhaps still not the best outline but hoping there more explanaition should be ok.

    Concerning

    Luke

    select l.line_id,                                                                                                                                         -- line line_id
            ROW_NUMBER() OVER (PARTITION BY l.line_id order by l.rowid )                                                                              -- optional sub id, to make submains unique in combination with line_id (guess this will be ordered
            sdo_lrs.CLIP_GEOM_SEGMENT(SDO_LRS.CONVERT_TO_LRS_GEOM(l.geometry ), branch_measure, branch_next_measure, 0.05)              -- actual clipping, needs convert to LRS apparently, start end end branch measure
            from
                   line l,                                                                                                                                            -- rejoin mainly to get the geometry again
                             (
                             select line_id,                                                                                             -- line_id
                                     branch_measure,                                                                                                              -- measure of the branches (from CASE WHEN
                                     LEAD(branch_measure, 1, 0) OVER (PARTITION BY line_id order by branch_measure) branch_next_measure   -- Analytical function LEAD will get the next branch measure form the following ordered records per line_id
                             from
                                  (
                                  select a.line_id,                                                                                                              -- line_id
                                          CASE when                                                                                                              -- CASE (assuming branch will touch only at one point) it will be either the start or the endpoint
                                                      sdo_lrs.find_offset(                                                                    -- of the branch that will TOUCH, we are checking this based on the offset which one is closest
                                                                               SDO_LRS.CONVERT_TO_LRS_GEOM(a.geometry),                                   -- requires convert to LRS geom
                                                                               sdo_lrs.geom_segment_start_pt(b.geometry),                                   -- if it is neccessary to deal with multiple possibilities we might better use a temp table to evalute better
                                                                               0.05                                                                                -- TOLERANCE (all tolereance should be seen with respect to resolution of the data
                                                                               )                                                                   -- IF feasible, let spatial take care of the snapping
                                                      <
                                                      sdo_lrs.find_offset(
                                                                               SDO_LRS.CONVERT_TO_LRS_GEOM(a.geometry),
                                                                               sdo_lrs.geom_segment_end_pt(b.geometry),
                                                                               0.05
                                                                               )
                                            THEN
                                                 sdo_lrs.find_measure(
                                                                           SDO_LRS.CONVERT_TO_LRS_GEOM(a.geometry),
                                                                           sdo_lrs.geom_segment_start_pt(b.geometry),
                                                                           0.05
                                                                           )
                                            ELSE sdo_lrs.find_measure(
                                                                            SDO_LRS.CONVERT_TO_LRS_GEOM(a.geometry),
                                                                            sdo_lrs.geom_segment_end_pt(b.geometry),
                                                                            0.05)
                                              END branch_measure
                                  from line a, line b                                                                                                      -- self join using main and branch that touches
                                       WHERE sdo_relate(b.geometry, a.geometry, 'mask=TOUCH') = 'TRUE'                                     -- Should be replaceable with sdo_join + self join optimsation
                                       AND a.line_type = 'main'
                                       AND b.line_type = 'branch'
                                  union all                                                                                                                        -- union all to get the 0 measure (startpoint) in the subquery as the beginning of the first clipping segment
                                       select line_id, 0 as branch_measure
                                       from line
                                  union all                                                                                                                         -- union all to get the last measure (endpoint) in the subquery as the beginning of the first clipping segment
                                       select line_id,
                                                 sdo_geom.sdo_length(geometry, 0.05) as branch_measure                                                  -- maybe better to use actual get measure form lrs endpoint but is the same if no spaecial measure are used
                                       from line
                                  )
                             ) b
                             where
                             branch_measure < branch_next_measure                                                                                          -- avoid duplicates (2 branches at same location on main (but also the last + 1 segment with last measure and default value 0 from LEAD
                             and
                             l.line_id = b.line_id                                                                                                              -- join on line-id to reuse the geom (or potential other attributes from original lines
                             ;
    
  • No one knows what mean these three lines?

    These three lines appear next to songs for the album, sometimes solid, sometimes translucent. Sometimes one or two of the lines are solid. I've attached a screenshot of the example.

    They appear in each of the configurations above if the song is downloaded for consultation offline. I can't find anything anywhere in the Apple support documentation to explain what they mean.

    Any help is appreciated!

    Those who resemble rating bars you see for each track of the album during the display of the albums on the iTunes Store. I have not seen those on my iPhone here in the Canada. Maybe Apple beta tests the functionality for some users or sites.

Maybe you are looking for