Display of query results

I wrote a request to give me monthly information on the activities of our users.  The works of query and the data are good, but I'm not a fan of how it displays the information that I have and wanted to know if there was a way for me to re - write the query to get the same results.  Here are examples.

Oracle Version: 11.2.0.2

Scenario of

Select ev.initiating_user, ad.display_name, count (*)

the event ev, auditdefinition ad

where ev.object_class_id = ad.event_class_id and ev.create_date between to_date('01-MAY-2014','dd-MON-yyyy') and to_date (31 May 2014 23:59:59 ',' JJ-ME-aaaa HH24:MI:SS)

Ad group. Display_name, ev.initiating_user

ad ranking. Display_name, ev.initiating_user;

Please note that the data themselves are not given 'real', but it should give you an idea of what I need.

initiating_user display_name Count (*)
User1Creation1
User2Creation23
util_3Creation456
User1View380
user4View

3490

user5View2309
util_3Change

120

user5Change4230Utilisateur6Change3489User7Change59

As you can see, a user may be listed through all the s different 'display_name '.  The display_name will generally always the 3 above, but I'll add another in a future later.  Essentially, it is pretty static.

My Question

How can I get the desired below display?

User1 User2 util_3 user4 user5 Utilisateur6 User7
Creation123456
View38034902309
Change1204230348959

Essentially, I want to make the header user names.  User names can change from one month to the next, is not the static data.  I read an article on 11 g - pivot.html and it discusses something with pivot and unpivot.  I tried to use the concept in my query, but cannot understand successfully where I'm wrong.  Here is my attempt.

Select * from)

Select ad.display_name, ev.initiating_user from auditdefinition ad, event ev where ad.event_class_id = ev.object_class_id

)

Pivot

(

Count (initiating_user)

for initiating_user in (select distinct initiating_user of event)

)

order by display_name;

When I try to launch it, I get an error message:

ORA-00936: lack of expression

00936 00000 - "missing expression.

* Cause:

* Action:

I tried to change my query to:

Select * from)

Select ad.display_name, ev.initiating_user from auditdefinition ad, event ev where ad.event_class_id = ev.object_class_id

)

Pivot

(

Count (EV.initiating_user)

for ev.initiating_user in (select distinct ev.initiating_user of the event ev)

)

order by display_name;

But I got an error message:

ORA-01748: only here allowed simple column names

01748 00000 - "names of only allowed simple column here.

* Cause:

* Action:

I looked at the error and I think that it is said that Oracle does not like the prefix "ev." in the "pivot ().  Can someone please help provide me assistance?  Thank you.

d

976563 wrote:

SELECT *.

DE)

SELECT ad.display_name, ev.initiating_user

To auditdefinition ad.

ev event

WHERE ad.event_class_id = ev.object_class_id

)

PIVOT XML

(

Count (initiating_user)

FOR initiating_user IN (SELECT DISTINCT initiating_user

OF the event)

)

ORDER BY display_name;

ORA-00918: column ambiguously defined

00918 00000 - "ambiguously defined column.

* Cause:

* Action:

I don't know where is the ambiguous column that oracle is not satisfied.  Any ideas?

Don't count on it, it won't, FOR the terms column should not be part of aggregate clause. (this my observation)

Count (initiating_user)


Either use

COUNT (1)

or

COUNT (any other column),

What should there be in a select query not among these ad.display_name, ev.initiating_user


976563 wrote:

SELECT *.

DE)

SELECT ad.display_name, ev.initiating_user,

To auditdefinition ad.

ev event

WHERE ad.event_class_id = ev.object_class_id

for example

SELECT *.

DE)

SELECT deptno,

employment,

SAL,

EmpNo

WCP

)

PIVOT XML

(

Noah Count (empno),

Sal Sum (SAL)

FOR EMPLOYMENT (job SELECT DISTINCT FROM emp)

)

ORDER BY deptno



Tags: Oracle Development

Similar Questions

  • How to get SQL Developer 4.1 to display the query result?

    SQL DEV 4.0.3.16.84 execution of a SELECT statement is stored in a .sql file causes the window of the query result of pop-up indicating the result of a SELECT statement.  SQL DEV 4.1 is not to do so.

    Oops on my part; my SQL formatting has been the root cause.  I got used to insert split without any character of comment lines in front of them.  For example:

    ==================================================

    Select funny business;

    The foregoing indicates the behavior described.

    --==================================================

    Select funny business;

    With the dash double comment shows, the SQL works very well.

    This is different than previous versions of SQL Developer, but is probably better functionality.  I'll try to mark it as answered, but anyone with the admin should certainly do so if I can't.

  • attempts to display the query results in 2 columns

    I'm trying to change someone elses existing of code to display the results of a query in 2 columns on a web page.

    The result of the existing code can be seen
    here

    Here is the code I am trying to change

    < table width = "95%" border = "0" align = "center" cellpadding = "4" cellspacing = "2" >
    < cfoutput query = "News" StartRowOptional = "" #StartRow_News # "LignesMax =" #MaxRows_News #">"
    < tr align = "center" class = "TEXTnormal" >
    < class nowrap = "style1 TEXTnormal" td >... < table >
    < /tr >
    < class tr = "TEXTnormal" >
    < td > < table width = "100%" border = "0" cellpadding = "0" cellspacing = "0" class = "TEXTnormal" >
    < b >
    < td > < cfif News.ImageNameThumb gt 0 >
    "< a href =" news_view.cfm? recordID = #News.ID #"> < img src =" "uploadedimages / #News.ImageNameThumb #" alt = "#News.ImageCaption #" hspace = "8" hspace = "0" border = "0" align = "left" > < / has >
    < cfelse >

    < / cfif > < table >
    < td > < a href = "" news_view.cfm? recordID = #News.ID # "class ="TEXThighlight"> #News.Title # < /a > - #News.Day #. #News.Month #. #News.Year # < br >"
    #News.Summary # < table >
    < /tr >
    < / table > < table >
    < /tr >
    < / cfoutput >
    < /table >

    I changed the above code to

    < table width = "95%" border = "0" align = "center" cellpadding = "4" cellspacing = "2" >
    < cfset LoopEndRow = CEILING(#EndRow_News#/2) >
    < cfloop
    index = "row".
    from = "#StartRow_News #
    to = "#LoopEndRow #
    step = "1" >
    < class tr = "TEXTnormal" >
    < cfset breaker = 0 >
    < cfloop
    index = "column".
    from = '0 '.
    to = '2 '.
    step = "1" >
    < cfoutput query = "News1" StartRowOptional = "" #StartRow_News # "LignesMax =" #MaxRows_News #">"
    < td width = "50%" >
    < table width = "100%" border = "0" cellpadding = "0" cellspacing = "0" class = "TEXTnormal" >
    < b >
    < td > < cfif News1.ImageNameThumb gt 0 >
    "< a href =" news_view.cfm? recordID = #News1.ID #"> < img src =" "uploadedimages / #News1.ImageNameThumb #" alt = "#News1.ImageCaption #" hspace = "8" hspace = "0" border = "0" align = "left" > < / has >
    < cfelse >

    < / cfif > < table >
    < td > < a href = "" news_view.cfm? recordID = #News1.ID # "class ="TEXThighlight"> #News1.Title # < /a > - #News1.Day #. #News1.Month #. #News1.Year # < br >"
    #News1.Summary # < table >
    < /tr >
    < / table > < table >
    < cfset breaker breaker + 1 = >
    < cfif breaker EQUAL 2 >
    < cfbreak >
    < / cfif >
    < / cfoutput >
    < / cfloop >
    < /tr >
    < / cfloop >
    < /table >

    The results of this code change can be see here

    as you can see what I did gives the number of columns (2)
    and the correct number of lines for the amount of data (3)
    However, each line shows the first 2 pieces of data returned by the query

    Can I change the output query so that it returns the data SET by the amount of data already out items?
    If so, how?



    #data #.




    closing tags

  • 3.1EA1: does not display the query results

    The results of any query I have run in 3.1EA1 do not show in the results of the query tab. When I run sqldeveloper.exe from the command prompt, there are no errors. Sqldeveloper 3.0 is very good.

    Oracle database: 10.2.0.4.0
    Java version: 1.6.0_26
    Operating system: Windows XP sp3 Prod

    This seems to be related to read/write to the history of SQL.
    You can see the question after a
    delete your SQL history
    or if you do not want to keep your history - zip C:\Documents and Settings\\Application Data\SQL Developer\SqlHistory folder before you delete it.

    Let me know.
    -Rambeau

  • The query results display help

    Hello

    I'm having a problem with the display of the results of my query result.

    When I cfloop on the results... the part number was released on 3 different ranks... when I want it on a single line, querying multiple tables... and you cannot use the option to group with the cfloop

    This is the query

    <cfquery datasource="wire" name="testss3">
       SELECT a.part AS pparts, a.wireid AS wireidA, a.strnds, a.wt, a.sps1, a.sps2, a.sps3, a.tin, b.slookup AS lid, b.wireid AS wireidB, b.reelid AS reelnmbr, d.reelid AS rlid, d.rname, d.rsku, d.rcost, e.plookupid, e.prctid, e.wireid AS wireidE, f.prctid, f.percentage, g.rsize
       FROM Mpart a, slookupt b, reeltbl d, prctlup e, prct f, spoolsize g
       WHERE a.wireid = b.wireid AND e.prctid = f.prctid AND a.wireid = e.wireid AND b.reelid = d.reelid AND g.spoolSizeid = b.spoolSizeid
       </cfquery>
    <table border="1" border="1">
     <tr>
            <td></td>
            <td bgcolor="#CCCCCC" class="style23">Part No.  </td>
            <td bgcolor="#CCCCCC" class="style23">Wt./Mft.</td>
            <td bgcolor="#CCCCCC" class="style23" colspan="3">Spool Sizes (Cost/ft.)</td>
            <td> </td>
          </tr>
                  
       <cfloop query="testss3"><cfoutput>
         <tr>
            <td></td>
               <td align="left" class="style23">#pparts# @</td>
                <td align="left" class="style23">#wt#</td>
               <td align="left" class="style23">
                #rsize# #rcost#  #wireidA#</cfoutput></cfloop></td>
            <td> </td>
           </tr>       
    </table>
    

    Reference No..M/m/Mft.Sizes in stock waiting (cost/pi)
    ground 10 @.31.431000 2.8000 1
    ground 10 @.31.432500 5.9800 1
    ground 10 @.31.435000 7.3000 1
    400A31.431000 2,8000 2
    400A31.432500 5,9800 2
    400A31.435000 7,3000 2
    8 ground @.50500 2,8000 4
    8 ground @.501000 5,9800 4
    8 ground @.505000 7,3000 4
    8 T @.50500 2,8000 5
    8 T @.501000 5,9800 5
    8 T @.505000 7,3000 5

    the first line should read 10 ground | 31.43. 1000 | 2500 | 5000

    rank 10 t | 31.43. 1000 | 2500 | 5000

    Any help would be appreciated!

    Thank you!

    You must nest CFOUTPUT tags to use the way you want.  One

    outside the loop to get the 'line after line only' and an inner to get all the

    subdetails in this line:

    roughly

  • Query results pane should display the entire XML following the execution of the query

    Hi, I'm trying to get the xml output results returned in sqldeveloper returned in full.

    they are truncated to.

    I tried the trick / * xml * / but that is implemented in the form xml cdata codes and other structures of nickname.

    Select xmlserialize (DOCUMENT

    XMLELEMENT ("root",

    XMLAttributes ('http://www.millicom.com' as 'xmlns'),

    XMLAGG)

    XMLELEMENT ("line",

    XMLFOREST (U.username,

    U.user_id,

    U.PASSWORD,

    U.ACCOUNT_STATUS,

    U.LOCK_DATE,

    U.EXPIRY_DATE,

    U.DEFAULT_TABLESPACE,

    U.TEMPORARY_TABLESPACE,

    U.CREATED,

    U.PROFILE,

    U.INITIAL_RSRC_CONSUMER_GROUP,

    U.EXTERNAL_NAME,

    U.PASSWORD_VERSIONS,

    U.EDITIONS_ENABLED,

    U.AUTHENTICATION_TYPE)))

    AS CLOB DASH)

    from dba_users U

    CROSS JOIN (select 1 of the double connect by level < = 10);

    Thanks for any help you can offer.


    JM

    Hi jm,

    In the line of query results, did scroll all the way to the right, then click twice on the «...» "at the end of the line to open the cell editor?

    So again, who does not show all the XML, it may be a problem with the version of the ojdb6.jar in use (11.2.0.3 client or later is required), or whether or not the JDBC OCI/thickness is used.  Read the following discussion: retrieve XMLTYPE based on very slow saved schema

    Kind regards

    Gary

    SQL development team

  • 3.0EA1: display of several results of the query in a spreadsheet

    Hello Forum,
    just after starting SQL Developer 3.0EA1 for the first time, I had a new tab for each SQL query result I entered in the worksheet. This is a great feature!
    But now I can not reproduce this behavior. All SQLs put their results into a single query result tab. The last of them wins.
    I have not found a preference setting to return several results of the query again.
    Did I miss something?
    I'm running on Windows XP and updated the parameters of 2.1.1.64. Perhaps that explains the rescue of the old behavior afer restart SQL Developer.
    I connect to Oracle 10.2.0.5 if it matters.

    Kind regards
    dhalek

    Preferences - Database - spreadsheet - automatically freeze the tabs of the result, or red pine under the result tabs button themselves.

    Have fun
    K.

  • Display of the results of the query with the column names unknown

    I use this code to grab the headers of columns in a select * statement. (I never know what table is queried out of 12 000 or more.) I want to make a loop on the column headers, then the query results in a web page table.

    < cfoutput >
    < cfset colHeaderNames = ArrayToList (recordset1.getColumnList ()) / >
    #colHeaderNames #.
    < / cfoutput >

    Is there a similar method or suggestions for the release of the results of the query - now that I know the column headings?

    If I understand correctly, you can do something like the code below.

  • View Blackberry Java Sqlite query result rows in the form of pages

    How can I display the rows resulting from the query sqlite one at a time in the form of question pages where a buttonfield (then) displays the next line (question) when you press. I was able to display all the rows at once with the following code:

    Statement st = null;
    try {}
    St = db.createStatement ("SELECT * FROM Questions by Qid asc");
    St.Prepare ();
    Cursor c = st.getCursor ();
    If (c == null) {}
    Dialog.Alert ("unable to retrieve from the database");
    }
    Line r;
    {while (c.Next ())}
    r = c.getRow ();

    String opt = "option" + r.getInteger (0);
    Option RadioButtonGroup = new RadioButtonGroup();
    Add (new LabelField (r.getInteger (0) + "." + r.getString (1)));
    Add (new RadioButtonField (r.getString (2), option, false));
    Add (new RadioButtonField (r.getString (3), option, false));
    Add (new RadioButtonField (r.getString (4), option, false));
    Add (new SeparatorField());
    }
    } catch (Exception e) {}
    e.printStackTrace ();
    } {Finally
    try {}
    St.Close ();
    } catch (DatabaseException e) {}
    }
    }

    But no progress with splitting into separate view. Do you know how to go about it?

    I thought the usual way to proceed would be for the SQL query to provide lines to return to the screen, and then the screen would have a loop by pushing another modal screen with the following Question.  If this player from the screen not from the query.  Who is?

  • Need help with a query result

    Oracle Version: 11.2.0.2.0

    I need assistance with the output of the query. Here is the table.

    With Tbl_Nm as

    (

    Select 'ABC1' SYSTEM_ID, REGION 'US', 'CHI' SUB_REGION 4000 BALANCE, to_date('1-JUN-2012 10:45:00 am', 'dd-mon-yyyy hh:mi:ss am') LAST_UPD_TIME, 'A' FLAG of union double all the

    Select 'PQR2', 'UK', 'LN', 2000, To_Date('1-JUL-2012 10:46:00 am', 'dd-mon-yyyy hh:mi:ss am'), has ' starting from dual Union All

    Select 'ABC1', 'IND","MAMA", 3500, To_Date('1-AUG-2012 11:47:00 am', 'dd-mon-yyyy hh:mi:ss am'), 'A' from dual Union All

    Select "LMN3", "US", "NJ", 2500, To_Date('1-SEP-2012 09:49:00 am', 'dd-mon-yyyy hh:mi:ss am'), 'A' from dual Union All

    Select "PQR2", "UK", "MC", 2600, To_Date('1-OCT-2012 04:45:00 am', 'dd-mon-yyyy hh:mi:ss am'), 'A' from dual Union All

    Select 'ABC1', 'US', 'NY', 3200, To_Date('1-OCT-2012 06:45:00 am', 'dd-mon-yyyy hh:mi:ss am'), has ' starting from dual Union All

    Select "LMN3", "UK", "BT", 2400, To_Date('1-NOV-2012 07:45:00 am', 'dd-mon-yyyy hh:mi:ss am'), has ' From Dual

    )

    Select * from tbl_nm

    I need the output below.

    PQR2 UK MC 2600 1 OCTOBER 2012 04:45

    ABC1 US NY 3500 October 1, 2012 06:45

    LMN3 UK BT 2500 November 1, 2012 07:45

    The need the disc according to this system_id flagged as "A". But if the last disc of 'd' then it must show that the amount, but the file should be displayed in 'A '.

    I've tried a few and got stuck. Help, please. Not able to get a balance '.

    This question is a bit similar to needing help with a query result

    With Tbl_Nm as

    (

    Select 'ABC1' System_Id, region 'US', 'CHI' Sub_Region, 4000 balance, To_Date('1-JUN-2012 10:45:00 am', 'dd-mon-yyyy hh:mi:ss am') Last_Upd_Time, 'A' flag of double Union All

    Select 'PQR2', 'UK', 'LN', 2000, To_Date('1-JUL-2012 10:46:00 am', 'dd-mon-yyyy hh:mi:ss am'), has ' starting from dual Union All

    Select 'ABC1', 'IND","MAMA", 3500, To_Date('1-AUG-2012 11:47:00 am', 'dd-mon-yyyy hh:mi:ss am'), 'A' from dual Union All

    Select "LMN3", "US", "NJ", 2500, To_Date('1-SEP-2012 09:49:00 am', 'dd-mon-yyyy hh:mi:ss am'), 'A' from dual Union All

    Select "PQR2", "UK", "MC", 2600, To_Date('1-OCT-2012 04:45:00 am', 'dd-mon-yyyy hh:mi:ss am'), 'A' from dual Union All

    Select 'ABC1', 'US', 'NY', 3200, To_Date('1-OCT-2012 06:45:00 am', 'dd-mon-yyyy hh:mi:ss am'), has ' starting from dual Union All

    Select "LMN3", "UK", "BT", 2400, To_Date('1-NOV-2012 07:45:00 am', 'dd-mon-yyyy hh:mi:ss am'), has ' From Dual

    )

    Select System_Id, region, Sub_Region, Balance, Last_Upd_Time of Tbl_Nm T1

    where t1. Last_Upd_Time = (select max (Last_Upd_Time) in the Tbl_Nm T2 where T1.) SYSTEM_ID = T2. SYSTEM_ID)

    So maybe you'd then

    ORDER BY DECODE(flag,'D',9,1) ASC...

    to get the Ds at the end of the list.

    or

    ORDER BY CASE WHAT flag = has ' (your other filters) AND then 9 or 1 end CSA,...

    HTH

  • new to 4.02, no grid or column names in the query results

    It is a bit strange, I have SQL Developer 4.02 just installed, and I don't see grid or column names in the query results.  Don't see anything useful in tools > Preferences, what don't get me?

    The worksheet gives you a couple of different ways to run a query...

    1. instruction execute sheet icon toolbar (large green arrow, or Ctrl + Enter).

    This produces a results tab of the query with the data displayed in a grid.

    2. worksheet icon toolbar Execute the Script (the small tip of the green arrow on lined paper, or F5).

    This produces a tab out of the Script with the data displayed on the printer.

    If execution of the statement to Execute the Script, using some SQL * most orders will remove the column headers:

    1. set the position

    2. set the pagesize 0 (or 1 or 2).

    Pagesize and linesize default is - 1.  By default, the spreadsheet is free for formatting output script as he wishes.  If you have not changed these settings in the spreadsheet, then see if you point to a startup script in Tools > Preferences > Database > name of the connection startup script file

    Kind regards

    Gary

    SQL DeveloperTeam

  • Limit the number of CMIS query results

    Hello
    Can we limit the number of CMIS query results
    my query is
    SELECT * from ora: t:IDC:GlobalProfile WHERE the ora: p:xRegionDefinition AS \'ALERTRD\'
    I want only newer 2 alerts to display.

    Thank you

    You use the CMIS query in a workflow of presenter content in WebCenter Portal? These documents provide a maxResults parameter to set.

  • How to clear the search query result set

    I dropped a search with the table query. When I search a value it is the display of the result, but when I click on the reset button, only the query Panel is reset to zero and not the table. What can I do to reset the table component associated with the query?
    When I click on the reset button, only the query panel goes to zero and no table.

    It will be reset nt table.

    What can I do to reset the table component

    Use of the component range reset. to do so.

    http://jobinesh.blogspot.in/2009/10/reset-content-of-Web-page.html
    http://myadfnotebook.blogspot.in/2011/05/making-reset-button-in-afquery.html trickles you want
    http://andrejusb.blogspot.in/2009/09/programmatical-reset-for-query-results.html

    -edited lately

    Published by: ADF7 on February 22, 2012 12:58 AM

  • Keep the query results set all paging

    I have a query back thouands of records. For do not impact performance display and paging, which would be the best way without use of query caching? Is it possible to keep the first recordset query time she and her use in Exchange?

    Load balancing definitely throws a wrinkle by using shared memory.  There are ways to address these problems, but they all come with the pros and cons, just basically choose what pros like you and what the disadvantages that you can live with.

    I.E. you can use sessions.  So when a user first access your application, all future queries are sent to the same server that processes requests for first.  But this means that if this server will see, all users currently glued to it are s.o.l.

    I saw other people using databases for the persistent memory.  But then, you have the LAG involved in obtaining data from the database on every request, although it should be easy fast queries to do this.  Side pro, it does not matter which server processes the request.

    It would be different then just re - run the original query every time, but rather store the original query results into a temporary table space so that any complexity which may exist should not be repeated.

  • Date format in the query result window Visual Studio

    Most of the seller tools allow you to change the date format to display datetime in its query results window.
    But .NET does not have this.
    The ability to change what should be in located in tools | Options, but this is not.
    Can it be added in the next version?
    ALTER SESSION SET NLS_DATE_FORMAT = 'HH DD-MON-RR' does not work. BTW.
    .NET or ODT too it rises.

    This might help:

    http://msdn.Microsoft.com/en-us/library/az4se3k1.aspx

    Ming Man

Maybe you are looking for

  • Cannot remove the tape on the printer cartridges that came with my new printer according to the instructions.

    Product name/number - Deskjet 1000 printer J110 Series Operating system - Windows 7 No error message, I can't get there No changes, he just arrived by mail The installation sheet says to remove the ink cartridges before pushing the transparent tape.

  • The local Boolean Variable vs Boolean reference

    I always spent Boolean values through local variables, but I just came across a Subvi, which passes a Boolean reference that then feeds a property node that sets the property "Value" of the value Boolean false.  What are the benefits of using the ref

  • Produce data of a loop with a structure of the event

    I'm relatively new to Labview programming (as discussed in my program below). I found a vi online which collects data from an analog USB card to 9237 bridge. The upper part of the vi is which collects the data. The original place the output into a ch

  • File AVI, DEP error

    Whenever I go into a directory with any type of .avi file inthe folder. With in few seconds normally appears aWindows of saying message explore a meet DEP error and will be closed.Initially, I used to read the file .avi without any problem. Guide me

  • Software Scanner & Pic editing does not work on my Dell PC (Win 7)

    There is one year, my pc Dell w/win 7 has a virus. I had removed it, but ever since then, I can't scan pictures & if I install photo editing software, it will not work. I have of course the files/drivers that this is possible are missing or corrupted