How to aggregate data in SQL Query

Hi,
I have Table1 field1 and field2. Combination of these fields form the key of this table.
Next I have Table2 with field3 and field4. field1 is the unique key for this table.
My query is:
select T2.field4||','||T1.field2 from T1 inner join T2 on T1.field1 = T2.field3;
In the result I want to aggregate the data by T2.field4
How do I that? Please help
Thanks in advance,
Raja

How to aggregate data in SQL Query By using aggregate functions and group by:
SQL> select object_type, count(*), sum(decode(status,'VALID',0,1)) inv_obs
  2  from all_objects
  3  group by object_type;
OBJECT_TYPE                     COUNT(*)              INV_OBS
CONSUMER GROUP                         2                    0
INDEX PARTITION                      970                    0
TABLE SUBPARTITION                    14                    0
SEQUENCE                             226                    0
SCHEDULE                               1                    0
TABLE PARTITION                      349                    0
PROCEDURE                             21                    0
OPERATOR                              57                    0
WINDOW                                 2                    0
PACKAGE                              313                    0
PACKAGE BODY                          13                    0
LIBRARY                               12                    0
PROGRAM                                9                    0
INDEX SUBPARTITION                   406                    0
LOB                                    1                    0
JAVA RESOURCE                        771                    0
XML SCHEMA                            24                    0
JOB CLASS                              1                    0
TRIGGER                                1                    0
TABLE                               2880                    0
INDEX                               4102                    0
SYNONYM                            20755                  140
VIEW                                3807                   72
FUNCTION                             226                    0
WINDOW GROUP                           1                    0
JAVA CLASS                         16393                    0
INDEXTYPE                             10                    0
CLUSTER                               10                    0
TYPE                                1246                    0
EVALUATION CONTEXT                     1                    0

Similar Messages

  • How to compare result from sql query with data writen in html input tag?

    how to compare result
    from sql query with data
    writen in html input tag?
    I need to compare
    user and password in html form
    with all user and password in database
    how to do this?
    or put the resulr from sql query
    in array
    please help me?

    Hi dejani
    first get the user name and password enter by the user
    using
    String sUsername=request.getParameter("name of the textfield");
    String sPassword=request.getParameter("name of the textfield");
    after executeQuery() statement
    int exist=0;
    while(rs.next())
    String sUserId= rs.getString("username");
    String sPass_wd= rs.getString("password");
    if(sUserId.equals(sUsername) && sPass_wd.equals(sPassword))
    exist=1;
    if(exist==1)
    out.println("user exist");
    else
    out.println("not exist");

  • Can we use session variables in BI publisher's Data Model SQL Query?

    Hi Experts,
    We need to implement Data level security in BI Publisher 11g.
    In OBIEE we do so by using session variables, so just wanted to ask if we can use the same session variables in BI Publisher as well
    ie can we include the where clause in the Data Models SQL Query like
    Where ORG_ID = @{biServer.variables['NQ_SESSION.INV_ORG']}
    Let me know your views on this.
    PS: We are implementing EBS r12 security in BI Publisher.
    Thanks

    Read this -> OBIEE 11g: Error: "[nQSError: 23006] The session variable, NQ_SESSION.LAN_INT, has no value definition." when Creating a SQL Query using the session variable NQ_SESSION.LAN_INT in BI Publisher [ID 1511676.1]
    Follow the ER - BUG:13607750 - NEED TO BE ABLE TO SET A SESSION VARIABLE IN OBIEE AND USE IT IN BI PUBLISHER
    HTH,
    SVS

  • How to select data from Sql server 2005 database tableinto oracle database table

    Hi,
    I have table text1 in sql server database and text2 in oracle database (11g). Now how to move data from SQL Server table into oracle table. So please help me how to do it.
    Thanks a lot in advance.
    rk
    OS: Windows 7 professional

    Hi,
    you can use export/import wizard and specify sql server as a source and oracle as destination.
    I hope this is helpful.
    Please Mark it as Answered if it answered your question
    OR mark it as Helpful if it help you to solve your problem
    Elmozamil Elamir Hamid
    MCSE Data Platform
    MCITP: SQL Server 2008 Administration/Development
    MCSA SQL Server 2012
    MCTS: SQL Server Administration/Development
    MyBlog

  • Re: How to converting from PL/SQL query to T-SQL query

    How to converting from PL/SQL query to T-SQL query... Its Urgent

    Download the
    SQL Server Migration Assistant for Oracle.  It will convert whole Oracle databases, or single queries or PL/SQL stored procedures.
    With caution that If your database is using Collation which is case sensitive SSMA will not work.SSMA doesnt guarantees 100% for conversion of Queries/stored proc /database if it fails to do so for some queries you will have to do it manually.
    But you can try
    Please mark this reply as the answer or vote as helpful, as appropriate, to make it useful for other readers

  • How Can I Make This Sql Query To Load Data Correctly (sql server)?

    Hi guys
    I have a datagridview where the third column is a custom column with all days
    of a month. It takes data with a query who distinct the column Improve.
    Here is the code :
    Private Sub fill_impro()
    dgImprove.Rows.Clear()
    Try
    Dim i As Integer = 0
    Dim query As String = "SELECT Improve,Price,Active,Idate FROM (SELECT Improve,Price,Active,Idate, ROW_NUMBER() OVER (PARTITION BY Price ORDER BY Price) AS rn FROM tblImprove) tmp WHERE rn = 1"
    cmd = New SqlCommand(query, clsMSSQL.con)
    myDR = cmd.ExecuteReader
    If myDR.HasRows Then
    While myDR.Read
    dgImprove.Rows.Add()
    dgImprove.Rows(i).Cells(0).Value = myDR.GetDecimal(myDR.GetOrdinal("Price"))
    dgImprove.Rows(i).Cells(1).Value = myDR.GetString(myDR.GetOrdinal("Improve"))
    Dim myday As Integer = DatePart(DateInterval.Day, myDR.GetValue(myDR.GetOrdinal("Idate")))
    dgImprove.Rows(i).Cells(myday + 1).Value = myDR.GetInt32(myDR.GetOrdinal("Active"))
    i = i + 1
    End While
    End If
    myDR.Close()
    Catch ex As Exception
    MsgBox(ex.Message, MsgBoxStyle.Critical, "Σφάλμα")
    End Try
    End Sub
    And here is the result :
    http://i60.tinypic.com/28gwf83.jpg
    The column Active value is 1.
    The problem is that column Active values are missing (red values in image).
    How can i fix that ?
    Thanks in advance

    try like this
    Dim Price As Decimal
    Dim improve As String = String.Empty
    While myDR.Read
    Dim myday As Integer = DatePart(DateInterval.Day, myDR.GetValue(myDR.GetOrdinal("Idate")))
    If Not (myDR.GetDecimal(myDR.GetOrdinal("Price")) = Price And myDR.GetString(myDR.GetOrdinal("Improve")) = improve) Then
    i += 1
    dgimprove.Rows.Add()
    dgimprove.Rows(i).Cells(0).Value = myDR.GetDecimal(myDR.GetOrdinal("Price"))
    dgimprove.Rows(i).Cells(1).Value = myDR.GetString(myDR.GetOrdinal("Improve"))
    Price = myDR.GetDecimal(myDR.GetOrdinal("Price"))
    improve = myDR.GetString(myDR.GetOrdinal("Improve"))
    End If
    dgimprove.Rows(i).Cells(myday + 1).Value = myDR.GetInt32(myDR.GetOrdinal("Active"))
    End While
    and change your sql statement to just
    SELECT Improve,Price,Active,Idate FROM tblImprove WHERE Active = 1

  • How Can I Make This Sql Query To Load Data Correctly (sql server 2014)?

    Hi guys
    I have a datagridview where the third column is a custom column with all days
    of a month. It takes data with a query who distinct the column Improve.
    SELECT Improve,Price,Active,Idate FROM (SELECT Improve,Price,Active,Idate, ROW_NUMBER() OVER (PARTITION BY Improve ORDER BY Improve) AS rn FROM tblImprove) tmp WHERE rn = 1
    And here is the result :
    http://i60.tinypic.com/28gwf83.jpg
    The column Active value is 1.
    The problem is that column Active values are missing (red values in image).
    How can i fix that ?
    Thanks in advance
     

    Hi, 
    Maybe you can try below code, I have changed the order by of the row_number(). Therefore it will sort on the date, and you will get the first date icm with improve cell. If this is not what you are looking for, please explain what the output should be. 
    SELECT Improve,Price,Active,Idate
    FROM
    SELECT Improve,Price,Active,Idate, ROW_NUMBER() OVER (PARTITION BY Improve ORDER BY ldate) AS rn
    FROM tblImprove
    ) tmp WHERE rn = 1
    Regards, 
    Reshma
    Please Vote as Helpful if an answer is helpful and/or Please mark Proposed as Answer or Mark As Answer when question is answered

  • How to create a Matrix table using this data in SQL Query Analyzer

    Hello all,
    I have a problem while I am trying to represent my Sql Table namely table1 in Matrix form
    my table Format is
    city1 city2 Distance--------------------------------------------------------
    Mumbai Delhi 100
    Delhi Banaras 50
    Mumbai Rajasthan 70
    Banaras haryana 40
    Mumbai Mumbai 0
    784 entries
    there are 784 cities each having link to other
    Now i want my output as
    Mumbai Delhi Banaras haryana
    Mumbai 0 100 -- --
    Delhi 100 0 50 --
    Banaras
    haryana
    respective distance from one city to other should be shown
    final Matrix would be 784*784
    I am using SQL Query Analyser for this
    Please help me in this regard

    I'm pretty much certain that you don't want to do this in pure SQL. So that means that you want to do it with a reporting tool. I'm not familiar with SQL Query Analyzer, but if it is in fact a reporting tool you'll want to consult its documentation looking for the terms "pivot" or perhaps "cross tab."

  • How to set fetchsize of sql Query when using Database Adapter.

    Hi All,
    I am using DatabaseAdapter to connect to database and retriving huge amount of data.For improvement in the performance I want to set the "fetchsize" of sql query. I know fetchsize can be preset in Java using Jdbc 2.0 API.Please let me know how to set this value in BPEL when using DBAdapter?
    Thanks
    Chandra

    I talked to the developer of the db adapter - and he told me this feature will be available in BPEL PM 10.1.3 (which is supposed to be production later this year, and a public beta soon). If this is an emergency I would recommend going throug Oracle support and have them file an enhancement for 10.1.2.0.2
    hth clemens

  • Help needed in Exporting tables data through SQL query

    Hi All,
    I need to write a shell script(ksh) to take some of the tables data backup.
    The tables list is not static, and those are selecting through dynamic sql
    query.
    Can any body tell help me how to write the export command to export tables
    which are selected dynamically through SQL query.
    I tried like this
    exp ------ tables = query \" select empno from emp where ename\= \'SSS\' \"
    but its throws the following error
    EXP-00035: QUERY parameter valid only for table mode exports
    Thanks in advance,

    Hi,
    You can dynamically generate parameter file for export utility using shell script. This export parameter file can contain any table list you want every time. Then simply run the command
    $ exp parfile=myfile.txt

  • How to aggregate data with BI Publisher using an OBIEE analysis

    Hello,
    I'm new with BI Publisher, and I have a concern about the ability for BIP to aggregate data.
    I am creating a data source from an OBIEE analysis containing the columns "Year", "Month", and "Revenue".
    I want to use this source for 1 report containing several pages. One of the page has a simple table displaying only the Year and the Revenue.
    But I get as many rows as number of months is the year.
    And I cannot find any way to have the data aggregate inside my PIB table.
    Can someone help me finding the solution?
    Many thanks in advance

    Hi,
    Unfortunalty BIP doesn't aggregate anything, like the BI server does. It will always show data on the lowest level.
    If you use a query on the BI-server let the BI server do the aggregation and just remove the "Month" column. If you don't want to remove it from your OBI analysis, copy the logical SQL from this analysis to BIP. And select OBIEE as a datasource.
    Then remove month from your query.
    Regards, Machiel

  • How to group data from SQL queries in XMLP Enterprise Edition

    Hi all,
    I have installed XMLP EE on a windows machine. I tried creating the data set with the type as SQL Query. In my case I have just joined the EMP and DEPT tables from the SCOTT schema:
    select     EMP.EMPNO as EMPNO,
         EMP.ENAME as ENAME,
         EMP.JOB as JOB,
         DEPT.DNAME as DNAME,
         EMP.DEPTNO as DEPTNO
    from     SCOTT.EMP EMP,
         SCOTT.DEPT DEPT
    where DEPT.DEPTNO=EMP.DEPTNO
    and DEPT.DNAME = nvl(:DeptName,DEPT.DNAME )
    I want that the data should be displayed in my report so that for each value of DNAME all the details (EMP.EMPNO, EMP.ENAME, EMP.JOB ) should be displayed as in master detail format in my XML output, so that it is easier to build the template using the <?for-each?> tags.
    Can anyone suggest how I can do this?
    I am facing another error :
    The report cannot be rendered because of an error, please contact the administrator.
    Can anyone help me with this too?
    Thanks.

    Hi
    On the error, have you tried running the report to generate data only ? If that is failing then you have an issue with your query or connection
    On the grouping, hopefully you have the Template Builder installed. That can help you build the grouping you want in the output. For this report and to get you started check out the Table Wizard. There is a screen in that flow allowing you to specify Grouping criteria.
    the following blog article may help too:
    http://blogs.oracle.com/xmlpublisher/2007/05/03#a265
    and this getting started with templates doc
    http://www.oracle.com/technology/products/xml-publisher/xmlpclient.html
    Regards
    Tim

  • Date in sql query problem

    Hi,
    I have a search form with 1 field (date picker) - the user chooses a date and a report based on a sql query is shown.
    I want the report to be based on only the month and year, and not the particular day.
    If there is a date picker (or something similar) for only month and/or year, then I can change my form, but I don't see this option.
    So, I'm trying to write my query to ignore the Day portion in the search form and just do a search based on the month and year, but i'm having trouble with this.
    This is my query...
    select d.dept, count(e.emp_id) "No. of Employees"
    from dept d, employees e
    where e.date_created = trunc(:P13_DATE, 'MONTH YYYY')
    and d.dept_id = e.dept_id
    group by dept
    order by dept
    How do I write the where clause so that the search is done only on month and year?
    Or otherwise, how can I change the search form to exclude the day from the date?
    Thanks.

    Hi,
    Oh, the invalid number is the result of :P13_DATE being a string value. all item values are actually strings (or varchar2 if you like) when you referencing them with ':Px_ITEM' format. With the pl/sql function there are 2 possible ways to reference item, namely the function: V('Px_ITEM') and NV('Px_ITEM'). Although in SQL varchar2 => number conversion can be dealed with by the SQL engine.
    Unfortunally there is no pl/sql method for getting a DATE of an date-picker item (based on its format mask etc.). Patrick Wolf has added this function in his ApExLib framework, function DV. I find this a nice extension.

  • How to find the backend  SQL query of the JSP page in OIC

    Does anybody how the best way to find the backend SQL QUERY of OIV JSP page?

    How To Generate Trace Files in in HTML/JSP (using Profile Option)
    •     • Note: This requires proper responsibility to set SQL Initialization statement using Profile option.      
         Step 1.     Login to the desired Form application.     
         Step 2.     Select +Profile >> System ('Find System Profile Values' screen will pop up)     
         Step 3.     Check 'User' and Type in the Username (in which the account for that user will be trace)     
         Step 4.     Type 'Initialization%' in the Profile box and Hit 'Find' (Click here for preview.)     
         Step 5.     In the User box, type the following statement and Hit 'Save' (Click here for preview)
         BEGIN FND_CTL.FND_SESS_CTL('','','TRUE','TRUE','','ALTER SESSION SET TRACEFILE_IDENTIFIER = TESTING MAX_DUMP_FILE_SIZE = 5000000 EVENTS ='||''''||' 10046 TRACE NAME CONTEXT FOREVER, LEVEL 12'||'''');END;     
         Note:     specify any name you like to identify your trace, in this case, testing is the end name on the trace. You can also specify the amount of data allowable to be in the trace, in this case, 5000000 is the amount set. Make sure you hit 'Save' afterwards.[Quotes in the statement are all 'Single' quotes.]
              specifying TRACEFILE_IDENTIFIER value is mandatory when setting up the trace using the above profile option value
         Step 6.     Login to HTML / JSP page with username/password and start your flow. (Everything you do once login to HTML / JSP will get trace.)     
         Step 7.     Logout of HTML / JSP application once you completed with your flow.      
         Step 8.     Go back to the Profile option in the Form application and delete the Initialization SQL statement, and Hit 'Save'.     
         Step 9.     Log in to the database server or login server and retrieve your trace file.
         Identify and retrieve the trace file using the tracefile_identifier specified in Step 5.
         In this case the tracefile_identifier is “TESTING”. (Click here for Trace file locations) *     
         Note:     If you need to regenerate your trace or tracing a new flow, then repeat Step 1 to Step 8. To avoid self-confusion, choose a different name for your trace identifier everytime you set to trace.     
         Step 10.     See TKPROF section on how to format trace file into readable text.
         Trace Options Definition
         No Trace          Tracing is not activated
         Activities will not get traced.
         Regular Trace
         (Level 1)          Contains SQL, execution statistics, and execution plan.
         Provides execution path, row counts as well as produces smallest flat file.
         Trace with Binds
         (Level 4)          Regular Trace plus value supplied to SQL statement via local variables.
         Trace with Waits
         (Level 8)          Regular Trace plus database operation timings that the SQL waited to have done in order to complete, i.e. disk access.
         Trace with Binds and Waits
         (Level 12)          Regular trace with both waits and binds information.
         Contains the most complete information and will produce the largest trace file.
    ****Send me an email to [email protected],I will share the document with you.

  • Data Display -- SQL Query?

    Hi
    This might be simple but, I have no idea.. how to achieve this via a simple SQL Query..
    Data in a column :
    1
    5
    6
    15
    25
    30
    35
    Should do a SELECT showing like this..
    1 5
    6 15
    25 30
    35 NULL
    Thanks!

    create table t1
    (numcol     number);
    insert into t1 values(1);
    insert into t1 values(5);
    insert into t1 values(6);
    insert into t1 values(15);
    insert into t1 values(25);
    insert into t1 values(30);
    insert into t1 values(35);
    commit;
    select odds.numcol, evens.numcol
    from
       select numcol
             ,row_number() over (order by numcol) rn
       from
          select numcol
                ,row_number() over (order by numcol) rn
          from   t1
       where mod(rn,2) <> 0
    )  odds
       select numcol
             ,row_number() over (order by numcol) rn
       from
          select numcol
                ,row_number() over (order by numcol) rn
          from   t1
       where mod(rn,2) = 0
    )  evens
    where odds.rn = evens.rn (+);
                  NUMCOL               NUMCOL
                       1                    5
                       6                   15
                      25                   30
                      35

Maybe you are looking for

  • How to open (run) report on client in excel ?

    Hello experts, i am using ERP having forms 10g and database 10g. in current scenario , when i run report , i will run in PDF format. when there is need to convert it in Excel then i have to use software Rep2Excel.exe software in d2k's HTML folder (fo

  • Single click folder name to expand folder in folder view?

    As with prior versions, in [Windows] Explorer's main window, you can enable hovering to select and single clicking to expand the folder (but that is a pain in the rear when working with files). Windows XP folder view nicely allowed single clicking th

  • HP laserjet CM2320 mfp series printer.

    My printer screen is just blue. There are no messages on the screen except the HP logo. All the menus does not rrespond. What will I do to reset it to the previous state of operation???

  • Dying shuffle... both lights on at the same time

    I got my shuffle a while ago, and recently it's been acting erratically. I've got an imported album off a CD on it, aswell as some songs from iTunes music store. Every so often when I'm listening to it, it makes a pop noise and goes dead. Also, both

  • How to move a widget from one section to another

    Hi, I try to move a widget from a page of a section to another page by using copy and paste but it doesn't work. I hear only a short sound, when I press cmd+v. I think it must be possible to move widgets to other places or to copy them. Please help m