GROUP BY column name

Hi
Is there anyway to use group by colum name?
Select field1,field2
from table
group by 1,2
Is it possible?

user544364 wrote:
Hi
Is there anyway to use group by colum name?
Select field1,field2
from table
group by 1,2
Is it possible?Do you mean group by column number?
No. You must specify the column names to group by. Only ORDER BY allows for column numbers to be referenced.

Similar Messages

  • List View - Remove Group By Headers - Column Names

    I have a List View web part using Group By. However, when you do that, it uses the Actual column name with a colon in the visual representation.
    Also, there is a bar with the name of the column showing.
    I don't want to have either of these showing. I have found pages on the net that tell you how to do this using SPD, but because that causes unghosting, we don't use SPD.
    Also, I found this, using Javascript:
    http://amitphule.blogspot.com/2011/10/hiding-group-headers-from-sharepoint.html
    This works. However, it removes the Editing components of the ribbon also - you can't go back later and do any editing.
    Does anyone have any other ideas on this?

    Hi,
    According to your post, my understanding is that you wanted to remove Group By Headers in the List View web part.
    I try to reproduce the issue using the code you provided, however, I can edit the items.
    The initial status:
    The final status:
    Best Regards,
    Linda Li
    Linda Li
    TechNet Community Support

  • Invalid column name for the group attribute.

    Hi,
    Please help, I m struck with this for the past 2 days.
    Basically i have  big query and with cfoutput and group attribute; i m displaying hte results..
    It has 4 levels of grouping.
    Also, the grouping column will be different every time the user choose it.so I'm building an array to do it.
    Suppose the user choose only 3 columns, I'm manually adding the 4th column so that array has 4 values all the time.
    At time, i m getting this error, the column name is invalid.
    Your help is highly appreciated.
    <cfoutput query="mtburbycust" group="#lstSQLOrderBy[1]#">
              <cfif currentRow EQ 1>
                  <cfset rowColor2 = 'CECE9E'/>
             <cfelse>
                 <cfif isdefined('Prevcolor')>
                    <cfif comparenocase(Prevcolor,rowColor3) EQ 0>
                        <cfset rowColor2 = 'A8E4FF'/>
                    <cfelse>
                        <cfset rowColor2 = 'CECE9E'/>
                    </cfif>
                </cfif>
              </cfif>
              <cfset Rowcolor = Rowcolor2/>
               <cfset Prevcolor = Rowcolor2/>
             <cfoutput group="#lstSQLOrderBy[2]#">       
                  <cfoutput group="#lstSQLOrderBy[3]#">
                <cfoutput group="#lstSQLOrderBy[4]#">    
                   <cfoutput>
    </cfoutput>
    </cfoutput>
                        </cfoutput>
                    </cfoutput>
                </cfoutput>
            </cfoutput>

    These tags are somewhat ambiguous, as they have no query attribute:
    <cfoutput group="#lstSQLOrderBy[2]#"> 
    <cfoutput group="#lstSQLOrderBy[3]#">
    <cfoutput group="#lstSQLOrderBy[4]#">

  • Error in nested group function used with column name.

    Hi Team,
    If i used nested group function with column name its not working. Could you please any one suggest me.
    How to use it.
    Regards,
    Venkat.
    Please find Spool ........
    SQL> select user_name,max(max(CNT)) from (select USER_NAME,count(*) CNT from v$open_cursor group by USER_NAME)
    2 group by user_name,CNT;
    select user_name,max(max(CNT)) from (select USER_NAME,count(*) CNT from v$open_cursor group by USER_NAME)
    ERROR at line 1:
    ORA-00937: not a single-group group function
    SQL> select max(max(CNT)) from(select USER_NAME,count(*) CNT from v$open_cursor group by USER_NAME)
    2 group by user_name;
    MAX(MAX(CNT))
    605

    Venkat wrote:
    Hi Sayan
    Its giving output like below, but not given maximum CNT.
    SQL> select user_name,max(CNT)from (select USER_NAME,count(*) CNT from v$open_cursor group by USER_NAME)
    2 group by user_name;
    USER_NAME MAX(CNT)
    BANES_LERG 6
    VENE_USER 8
    USER3 339
    DBUS 106
    VEL_USER 37
    SYS 597
    6 rows selected.Check it - Re: Error in nested group function used with column name.
    and previous post

  • How to give alias name for group of columns.

    the below is the query to get Columns. But, i need to make single alias name to all the column which i get. I need to get column names also event, domain, entity, bpdid. Above columns should be under single alias name like 'baseMessage'. Please advise on this.
    select (select decode(ICKD_CHR_KY1_ID,'I','New','D','Cancelled','U','Modified') from ICKD where ICKD_APLN_ID = 'CSTCOM' and ICKD_NUM_KY1_ID = 1438227010) event, 'Client' domain, 'CustomerCommunication' entity, 'General' scope, (select ICKD_NUM_KY6_ID from ICKD where ICKD_NUM_KY1_ID = 1438227010 and ICKD_APLN_ID = 'CSTCOM') bpdId from dual;

    ; WITH CTE AS (
        SELECT Case When  sum(b.targetTotal) > 0 then  Sum(b.targetTotal)  
                          else 0
               end as Profttarget,
               Case When  sum(a.salestotal) > 0 then  Sum(a.salestotal)  
                          else 0
               end as Sales,
               Case When  sum(a.salescost) > 0 then  Sum(a.salescost)  
                    else 0
               end as SalesCost
        From  Sales A
        JOIN  Target B A.salesdate = B.salesdate
    SELECT Profttarget- ( Sales - SalesCost ) as TargetRequired
    FROM   CTE
    This gives you a query that runs in SQL Server.
    But it does not look right to me. I don't know what the keys of these tables are, but is it really salesdate in both? And even if it is, the join still looks strange.
    Erland Sommarskog, SQL Server MVP, [email protected]

  • Unable to reorder/change column names on interactive single row view

    I have created an interactive report and grouped my columns to display nicely in a single row view report. However, once I initially add the columns to a group, I am unable to reorder them. I can move them up and down the list, but the changes don't save. Also, I have gone through column by column and unchecked the box that says Use Same Text for Single Row View and expanded the column name. However, the single row view still displays what is in the master report. I've tried closing out my browser completely and reopening, but I am still not seeing my changes. Any suggestions?

    I also just stumbled about the "Use Same Text for Single Row View" option actually doing nothing - in Single Row View I still get the label text from "Column Heading", no matter what I enter in "Single Row View Label".
    I had to adjust a column width using a span tag in the heading (as this seems to be the only way to do that - any other suggestions I found adding style information to the region header had no effect), and now that tag is displayed in the Single Row View label.
    I can live with that for now, but it's not really nice.
    Is this a known bug? Didn't find anything else in the forum regarding this problem so far.
    Holger

  • How to select columns in a table by their column id and not the column name

    Hello,
    How do you select columns from a table based on their column_id.
    I have create a view
    but other than Select * , i cant now select one just one column from it
    the view as follow:
    create view count_student as
    select a.acode "acode",aname "Activity Name",count(ae.acode) "Number of student joined"
    from aenrol ae, activity a
    where a.acode= ae.acode
    group by a.acode,aname;

    The issue is that you have decided to use quoted column names. A pretty horrible idea (mostly for the reasons that you are now finding).
    Re-create the view and get rid of the silly double quotes.

  • Re: Column Name as Parameter in Oracle Procedure

    Hi,
    I've successfully compiled the following procedure:
    CREATE OR REPLACE PROCEDURE CREATE_MEASURES_IND_RPT(
        pSTART_DT                                    IN date
    ,   pEND_DT                                         IN date  
    ,   PGEO_DIMENSION_COLUMN               IN VARCHAR2
    AUTHID CURRENT_USER IS
    BEGIN
    DECLARE
        START_DT Date      := pSTART_DT;
        END_DT     Date      := pEND_DT;
    text_ip_adjusted varchar2(10000):='
      select
        replace(fiscal_yr,''/'') as fiscal_year,
        NVL(f_quarter(is_date(disdate,''yyyymmdd'')),''Year'') AS TIME_PERIOD_TYPE,
        NVL('||PGEO_DIMENSION_COLUMN||',''Province'') as geo_desc
        from data_table A,
                postal_code_table B
        where POSTCODE = B.POSTALCODE
          AND (is_date(disdate,''yyyymmdd'') >= :1 and is_date(disdate,''yyyymmdd'') < :2)
        GROUP BY
        replace(fiscal_yr,''/''),
        ROLLUP(f_quarter(is_date(disdate,''yyyymmdd''))),
        ROLLUP('||PGEO_DIMENSION_COLUMN||');
    begin
    EXECUTE IMMEDIATE text_ip_adjusted using START_DT,END_DT; COMMIT;
    END;
    END CREATE_MEASURES_IND_RPT;
    /When I try and execute the procedure, I get the following error:
    ORA-00936: missing expression
    ORA-06512: at "CREATE_MEASURES_IND_RPT", line 36
    ORA-06512: at line 1The data table has date strings which need to be converted to dates using an "IS_DATE" function I've created which is while you'll see the is_date function used. The procedure works fine when I don't include the PGEO_DIMENSION_COLUMN as a parameter so I suspect that I haven't reference the name of the column properly. Essentially, I need my procedure to be able to specify a Column Name in the Postal Code table to use as a group by field.
    Any help would be appreciated.
    Thanks,
    Ed

    Hi,
    spalato76 wrote:
    Hi,
    I've successfully compiled the following procedure:
    CREATE OR REPLACE PROCEDURE CREATE_MEASURES_IND_RPT(
    pSTART_DT                                    IN date
    ,   pEND_DT                                         IN date  
    ,   PGEO_DIMENSION_COLUMN               IN VARCHAR2
    AUTHID CURRENT_USER IS
    BEGIN
    DECLARE
    START_DT Date      := pSTART_DT;
    END_DT     Date      := pEND_DT;
    text_ip_adjusted varchar2(10000):='
    select
    replace(fiscal_yr,''/'') as fiscal_year,
    NVL(f_quarter(is_date(disdate,''yyyymmdd'')),''Year'') AS TIME_PERIOD_TYPE,
    NVL('||PGEO_DIMENSION_COLUMN||',''Province'') as geo_desc
    from data_table A,
    postal_code_table B
    where POSTCODE = B.POSTALCODE
    AND (is_date(disdate,''yyyymmdd'') >= :1 and is_date(disdate,''yyyymmdd'') < :2)
    GROUP BY
    replace(fiscal_yr,''/''),
    ROLLUP(f_quarter(is_date(disdate,''yyyymmdd''))),
    ROLLUP('||PGEO_DIMENSION_COLUMN||');
    begin
    EXECUTE IMMEDIATE text_ip_adjusted using START_DT,END_DT; COMMIT;
    END;
    END CREATE_MEASURES_IND_RPT;
    /When I try and execute the procedure, I get the following error:
    ORA-00936: missing expression
    ORA-06512: at "CREATE_MEASURES_IND_RPT", line 36
    ORA-06512: at line 1The data table has date strings which need to be converted to dates using an "IS_DATE" function I've created which is while you'll see the is_date function used. The procedure works fine when I don't include the PGEO_DIMENSION_COLUMN as a parameter so I suspect that I haven't reference the name of the column properly. Essentially, I need my procedure to be able to specify a Column Name in the Postal Code table to use as a group by field.
    Any help would be appreciated.
    Thanks,
    EdIt l;ooks like you're missing a single-quote at the very end of the expression being assigned to text_ip_adjusted.
    ...       ROLLUP(' || PGEO_DIMENSION_COLUMN || ')';How will you handle the output from that dynamic query? Maybe you should be opening a cursor.

  • I need the "Real" Table / Table Column names from a sql view

    Firstly, we have a system with ~1000 tables and ~250 views.  We have field level security on the table columns (in our code)
    Now we have a lot of views which select data from the tables, but I need to get the "Table Column Name" that is linked in the view. 
    I know there are view columns that is not linked to a specific table column, (or concatenation of columns) so those columns can just return NULL.
    From the sample you will see there is a view selecting data from another view.  I know it is not the best sql performance (execution path) but that is another topic on its own.
    I went through a lot of the sys.* stored procs or sys.* views to try and figure out if there is a view that we can use to get the expected results.
    here is the sql code:
    if
    Exists (select
    * from
    sys.all_objects
    where name =
    'AliasView2')
    drop view dbo.AliasView2
    if
    Exists (select
    * from
    sys.all_objects
    where name =
    'AliasView1')
    drop view dbo.AliasView1
    if
    Exists (select
    * from
    sys.all_objects
    where name =
    'Table4')
    BEGIN
    alter table dbo.Table4
    DROP CONSTRAINT [FK_T4_T3]
    alter table dbo.Table4
    DROP CONSTRAINT [PK_T4_Constraint]
    drop table dbo.Table4
    END
    if
    Exists (select
    * from
    sys.all_objects
    where name =
    'Table3')
    BEGIN
    alter table dbo.Table3
    DROP CONSTRAINT [FK_T3_T2]
    alter table dbo.Table3
    DROP CONSTRAINT [PK_T3_Constraint]
    drop table dbo.Table3
    END
    if
    Exists (select
    * from
    sys.all_objects
    where name =
    'Table2')
    BEGIN
    alter table dbo.Table2
    DROP CONSTRAINT [FK_T2_T1]
    alter table dbo.Table2
    DROP CONSTRAINT [PK_T2_Constraint]
    drop table dbo.Table2
    END
    if
    Exists (select
    * from
    sys.all_objects
    where name =
    'Table1')
    BEGIN
    alter table dbo.Table1
    DROP CONSTRAINT [PK_T1_Constraint]
    drop table dbo.Table1
    END
    create
    Table dbo.Table1
    T1_PK        int
    NOT NULL
    Identity(1, 1)
    CONSTRAINT [PK_T1_Constraint]
    PRIMARY KEY (T1_PK),
    T1_Field1    varchar
    NULL,
    T1_Field2    varchar
    NULL,
    create
    Table dbo.Table2
    T2_PK        int
    NOT NULL
    Identity(1, 1)
    CONSTRAINT [PK_T2_Constraint]
    PRIMARY KEY (T2_PK),
    T2_Field1    varchar
    NULL,
    T2_Field2    varchar
    NULL,
    T2_FK        int
    NOT NULL
    CONSTRAINT [FK_T2_T1]
    FOREIGN KEY (T2_FK)
    REFERENCES dbo.Table1
    (T1_PK)
    create
    Table dbo.Table3
    T3_PK        int
    NOT NULL
    Identity(1, 1)
    CONSTRAINT [PK_T3_Constraint]
    PRIMARY KEY (T3_PK),
    T3_Field1    varchar
    NULL,
    T3_Field2    varchar
    NULL,
    T3_FK        int
    NOT NULL
    CONSTRAINT [FK_T3_T2]
    FOREIGN KEY (T3_FK)
    REFERENCES dbo.Table2
    (T2_PK)
    create
    Table dbo.Table4
    T4_PK        int
    NOT NULL
    Identity(1, 1)
    CONSTRAINT [PK_T4_Constraint]
    PRIMARY KEY (T4_PK),
    T4_Field1    varchar
    NULL,
    T4_Field2    varchar
    NULL,
    T4_FK        int
    NOT NULL
    CONSTRAINT [FK_T4_T3]
    FOREIGN KEY (T4_FK)
    REFERENCES dbo.Table3
    (T3_PK)
    GO
    --Create a basic view to select some data
    CREATE
    VIEW dbo.AliasView1
    AS
    select
    t2.T2_FK as Table2_ForeignKey,
    t1.T1_Field1 as Table1_FieldOne,
    t2.T2_Field1 as Table2_FieldOne
    FROM Table1 t1
    Left outer
    join Table2 t2 on t2.T2_FK
    = t1.T1_PK;
    GO
    --Create another view that select basic data, and also selecting data from view 1
    CREATE
    VIEW dbo.AliasView2
    AS
    select
    v1.Table1_FieldOne
    as Table1_FieldOne,     
    v1.Table2_FieldOne
    as Table2_FieldOne,  
    t3.T3_Field1 as Table3_FieldOne,
    t3.T3_Field2 
    FROM Table3 t3
    Left outer
    join AliasView1 v1 on v1.Table2_ForeignKey
    = t3.T3_PK;
    GO
    --My attempt to get the desired output, but no luck
    SELECT 
    col.COLUMN_NAME as AliasColumnName, col.DATA_TYPE, col.CHARACTER_MAXIMUM_LENGTH
    as max_length, colu.*
    FROM
    information_schema.COLUMNS col
    left
    outer join
    (SELECT 
    VIEW_SCHEMA, VIEW_NAME, COLUMN_NAME,
    min(TABLE_NAME)
    as TABLE_NAME
    FROM information_schema.VIEW_COLUMN_USAGE colu
    WHERE VIEW_NAME =
    'AliasView2'
    Group by VIEW_SCHEMA, VIEW_NAME, COLUMN_NAME
    ) COLU ON colU.VIEW_NAME
    = col.TABLE_NAME
    and colu.COLUMN_NAME
    = col.COLUMN_NAME
    left
    outer join
    (select a.name
    as TableName, c.name
    as FieldName
    from sys.foreign_key_columns fk
    join sys.all_objects a
    on a.object_id
    = fk.parent_object_id
    join sys.all_columns c
    on c.object_id
    = a.object_id
    and c.column_id
    = fk.parent_column_id
    join sys.all_objects ar
    on ar.object_id
    = fk.referenced_object_id
    join sys.all_columns cr
    on cr.object_id
    = ar.object_id
    and cr.column_id
    = fk.referenced_column_id
    join sys.schemas scr
    on scr.schema_id
    = ar.schema_id
    ) fks on fks.TableName
    = colu.TABLE_NAME
    and fks.FieldName
    = colu.COLUMN_NAME
    WHERE COL.TABLE_NAME
    = 'AliasView2'
    order
    by col.ORDINAL_POSITION
    This is the results being returned: (That is not 100% what I am looking for)
    AliasColumnName
    DATA_TYPE
    max_length
    VIEW_SCHEMA
    VIEW_NAME
    COLUMN_NAME
    TABLE_NAME
    Table1_FieldOne
    varchar
    1
    dbo
    AliasView2
    Table1_FieldOne
    AliasView1
    Table2_FieldOne
    varchar
    1
    dbo
    AliasView2
    Table2_FieldOne
    AliasView1
    Table3_FieldOne
    varchar
    1
    NULL
    NULL
    NULL
    NULL
    T3_Field2
    varchar
    1
    dbo
    AliasView2
    T3_Field2
    Table3
    The desired results must be like the following:
    AliasColumnName
    DATA_TYPE
    max_length
    VIEW_SCHEMA
    VIEW_NAME
    COLUMN_NAME
    TABLE_NAME
    Table1_FieldOne
    varchar
    1
    dbo
    AliasView2
    T1_Field1
    Table1
    Table2_FieldOne
    varchar
    1
    dbo
    AliasView2
    T2_Field1
    Table2
    Table3_FieldOne
    varchar
    1
    dbo
    AliasView2
    T3_Field1
    Table3
    T3_Field2
    varchar
    1
    dbo
    AliasView2
    T3_Field2
    Table3
    NOTE:  the COLUMN_NAME and TABLE_NAME must the REAL field of the TABLE it belongs to and not only ONE LEVEL Higher’s ALIAS View Name

    Now we have a lot of views which select data from the tables, but I need to get the "Table Column Name" that is linked in the view.
    If you are using SQL Server 2012/2014, then you can use
    sys.dm_exec_describe_first_result_set (Transact-SQL) to gte the informations.
    Olaf Helper
    [ Blog] [ Xing] [ MVP]

  • Crystal Report - NULL values mapped to Column names in reports

    Hai,
    I am using rows of data retrived from the SQL Server 2005 Express and sometimes the column names are NULL , I want to set a default value to this NULL value and set it as Data axes label / Group axes values, can some one please help me with this issue.
    Thank you in advance.
    Vijay

    I resolved this issue myself, this can be set as other Data Labels, Group Label or Series Riser's properties too, left-click twice until the blank item is selected and then right click and select "Edit Axis Label" item and here it can edited with the new value(text).

  • How to pass column name as a   values from one page  to another

    hi
    i have created a report(pivot) from a table
    SQL> SELECT * FROM T;
    C1  C2          C3 D                SEQ
    A   AA           2                    1
    A   AB           3                    2
    A   AC           2                    3
    B   AB           5                    4
    B   AC           6                    5
    SQL> SELECT C1
      2  ,NVL(MAX(CASE WHEN C2='AA' THEN C3 END),'') AA
      3  ,NVL(MAX(CASE WHEN C2='AB' THEN C3 END),'') AB
      4  ,NVL(MAX(CASE WHEN C2='AC' THEN C3 END),'') AC
      5  ,SUM(C3) FROM T GROUP BY C1;
    C1          AA         AB         AC    SUM(C3)
    A            2          3          2          7
    B                       5          6         11
    SQL>
    my requirement in Apex is like this(reverse)
    eg-
    when i click on cell values '2' then,it should return
    C1  C2          C3 D                SEQ
    A   AA           2                    1
    {quote}how to pass column name as a  values from one page to another
    for example i have to pass 'c2' as a value to next page{quote}for report pivot you can reffer below link
    Report
    Amu

    thanks for your reply
    i 'm doing what exactly you mention here .
    my problem here is
    i have 15 columns
    i am executing a query based on the values of the column(column name)  in the target page
    1)here i am passing(all) the column values to the next page-but  i want to pass only one column values(column name)
    when i click on any cell of that  column
    OR
    2)i can pass all column name to target page -there(in the target page) i can filter out
    i think option 1 would good if you filter out the unwanted columns
    Regards
    Amul

  • Changing the Column names / alias

    Hi,
    I have an oracle query and it works fine.
    select q.sname,
    SUM( decode(p.nprofile1,10,1,0)) as "0 - 5",
    SUM( decode(p.nprofile1,9,1,0)) as "6 - 10",
    SUM( decode(p.nprofile1,8,1,0)) as "11 - 15",
    SUM( decode(p.nprofile1,7,1,0)) as "16 - 19",
    SUM( decode(p.nprofile1,6,1,0)) as "20 - 20",
    SUM( decode(p.nprofile1,5,1,0)) as "21 - 27",
    SUM( decode(p.nprofile1,4,1,0)) as "28 - 30",
    SUM( decode(p.nprofile1,3,1,0)) as "31 - 40",
    SUM( decode(p.nprofile1,2,1,0)) as "41 - 45",
    SUM( decode(p.nprofile1,1,1,0)) "46 - Over",
    COUNT(q.sname) "TOTAL"
    from task_core@cds t, cor_queue q, profile_core@crb p
    where t.nmboxid = q.nmboxid
    and p.ncodaid = t.nobjectid
    and p.ntype=2
    GROUP BY q.sname
    ORDER BY q.sname
    It generates a Cross-tab sort of result and I am using the decode function to generate the result.
    My problem is that right now I am using hardcoded column names or alias for the columns generated by the decode function. eg. "0-5", "6-10" etc.
    I have another table which contains these values ("0-5","6-10"). I would like to know instead of hard coding the column names like
    SUM( decode(p.nprofile1,10,1,0)) as "0 - 5"
    can we retrieve the values from the Other table that contains the values "0-5","6-10" etc and display it there in the decode function?
    Pls help me with this issue
    Thanks
    Gilles

    hi,
    the column names are always fixed. You can try dynamic sql in pl/sql or spool then execute, but in pure sql, it is not possible

  • Problem in displaying row vale as column name

    Hello Experts,
    Please help me,its very urgent....
    i want to dispaly a column value as a column name.
    i have two column into selete statement and i want to dispaly one column value as a column name and other column value as a single row.
    My query is :
    SELECT MAX(DECODE (NAME,'virtualDeviceId',VALUE))vdid ,
    MAX(DECODE (NAME,'virtualDeviceType',VALUE)) vdevtype,
    MAX(DECODE (NAME,'domainName',VALUE)) vdevtype1,
    MAX(DECODE (NAME,'sCTPPortSip',VALUE)) vdevtype2,
    MAX(DECODE (NAME,'signallingIpAddress',VALUE)) vdevtype,
    MAX(DECODE (NAME,'signallingNetworkMask',VALUE)) vdevtype,
    MAX(DECODE (NAME,'uDPPort',VALUE)) vdevtype,
    MAX(DECODE (NAME,'uDPPortEnum',VALUE)) vdevtype,
    MAX(DECODE (NAME,'sCTPPort',VALUE)) vdevtype,
    MAX(DECODE (NAME,'sCTPPortM3UA',VALUE)) vdevtype FROM(          
    SELECT extractvalue(VALUE(l),'/S109:trafficParameters/S109:name'
    , 'xmlns="http://itprogrammes.intra.bt.com/pdb/capabilities/ManageDaaliResource/2005/11/16" xmlns:header="http://wsi.nat.bt.com/2005/06/StandardHeader/" xmlns:S97="http://ccm.intra.bt.com/2005/11/16/LIB/Info/CCM/AnalysisModel/Services" xmlns:S109="http://ccm.intra.bt.com/2005/11/16/LIB/Info/MTOSI"') NAME,
         extractvalue(VALUE(l),'/S109:trafficParameters/S109:value'
    , 'xmlns="http://itprogrammes.intra.bt.com/pdb/capabilities/ManageDaaliResource/2005/11/16" xmlns:header="http://wsi.nat.bt.com/2005/06/StandardHeader/" xmlns:S97="http://ccm.intra.bt.com/2005/11/16/LIB/Info/CCM/AnalysisModel/Services" xmlns:S109="http://ccm.intra.bt.com/2005/11/16/LIB/Info/MTOSI"') VALUE
         FROM INTERFACE_MESSAGE_DESTINATION imd ,TABLE(xmlsequence(EXTRACT(XMLTYPE(imd.remote_request),'/activateConnection_Payload/jobBody/subnetworkConnection/S109:aEndTerminationPoint/S109:managedElement/S109:physicalTerminationPoint/S109:connectionTerminationPoint/S109:trafficDescriptor/*'
    , 'xmlns="http://itprogrammes.intra.bt.com/pdb/capabilities/ManageDaaliResource/2005/11/16" xmlns:header="http://wsi.nat.bt.com/2005/06/StandardHeader/" xmlns:S97="http://ccm.intra.bt.com/2005/11/16/LIB/Info/CCM/AnalysisModel/Services" xmlns:S109="http://ccm.intra.bt.com/2005/11/16/LIB/Info/MTOSI"'))) l
    WHERE message_id ='NIAS/0000041608') GROUP BY VALUE ;
    output is :
    Col1 Col2 col3 col4 col5 col
    1.'1001105'          '1001105'                                   
    2. 'MGC'                                        
    3.'value' 'value' 'value'
    output display : MGC in Col2 and in row 2, 'values' are in col4 and col5 and in row 3.
    I want all values in a single row.
    Please help me
    Surender Rana

    It is ugly to force multiple rows into a single row. But it can be done and can be done dynamically as the following approach shows.
    SQL> create or replace type TStrings as table of varchar2(4000);
    2 /
    Type created.
    SQL>
    SQL> create or replace function ForceColumns( cur SYS_REFCURSOR ) return TStrings is
    2 setCols TStrings;
    3 setResults TSTrings;
    4 begin
    5 setResults := new TStrings();
    6 loop
    7 fetch cur into setCols;
    8 exit when cur%NOTFOUND;
    9
    10 if setCols.Count > 0 then
    11 setResults.Extend( setCols.Count );
    12 for i in 1..setCols.Count
    13 loop
    14 setResults( setResults.Count-i+1 ) := setCols(i);
    15 end loop;
    16 end if;
    17 end loop;
    18
    19 return(setResults);
    20 end;
    21 /
    Function created.
    SQL>
    SQL> select
    2 ForceColumns(
    3 CURSOR(
    4 select TStrings(object_id,object_name,object_type) from user_objects where rownum <= 5
    5 )
    6 ) as RESULT_SET
    7 from dual
    8 /
    RESULT_SET
    TSTRINGS('TABLE', 'A', '70998',
    'PROCEDURE', 'ABC', '54360',
    'TABLE', 'ANIMALS', '84829',
    'TABLE', 'B', '69604',
    'PROCEDURE', 'BUILDNAMEMAP', '70155')
    SQL>Note that as the row can contain any number of columns, it needs to be dynamic. This approach uses a collection type called TStrings to achieve this.

  • JTable column names with custom model

    I'm having problems with column names in a JTable which uses a custom model. For some reason, the colums are being shown as A, B, C etc. The data, however, displays fine.
    This is the code which constructs the table.
    MyTableModel tableModel = new MyTableModel(myArrayList);
      myTable = new JTable(tableModel);
      myTable.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
      myTable.setFillsViewportHeight(true);This is the class, MyTableModel
    class MyTableModel extends AbstractTableModel {
            private ArrayList<Account> data;
            private String[] colNames = {"", "Name","Type","Group","Created","Modified"};
            public MyTableModel(ArrayList<Account> data) {
                this.data = data;
            public int getRowCount() {
                return data.size();
            public int getColumnCount() {
                return 6;
            public Object getValueAt(int row, int col) {
                Account account = (Account)data.get(row);
                switch(col) {
                    case 0:
                        return account.getIcon();
                    case 1:
                        return account.getName();
                    case 2:
                        return account.getType();
                    case 3:
                        return account.getGroup();
                    case 4:
                        return account.getDateCreated();
                    case 5:
                        return account.getDateModified();
                    default:
                        return "";
            public String getColumName(int index) {
             System.out.println("N:"+colNames[index]);
                return colNames[index];
        }When the table is displayed, nothing's displayed to the console, but I'd have thought getColumnName would print the current column name. Am I missing something obvious?

    Oh great. I'll go back under my rock.
    Thanks =)

  • Finding column name in database

    Hi all..
    I want to find each column name, how many tables this column name is there
    in database.
    For single colum, i can find by using this query..
    select a.COLUMN_NAME, a.TABLE_NAME from all_tab_columns a where
    a.OWNER='DC_ERD' and a.COLUMN_NAME ='ACCESSORY_MAKER'
    If i want to find for each column present in the database, can anybody please tell
    me if it is possible in sql or pqsql is needed.
    Thanks in advance,
    Pal

    Are you asking about the number of tables, it's been used or the tables list?
    select column_name, count(table_name)
    from all_tab_columns
    group by column_nameCheers
    Sarma.

Maybe you are looking for