How to extract several Max (amount) with sql

Hello

I have this problem,

I hace this table

DISPLAY_NAME, MSISDN TRANSACTIONS

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

CM, SA - MERCHANT I 829882904 75

CM, SA - MERCHANT I 827102931 43

CM, SA - MERCHANT I 17 824034968

CM, SA - II MERCHANT 827102931 48

4 selected lines.

And I need to get the records corresponding to the highest trasactions by DISPLAY_NAME

The must Resulet be something like

DISPLAY_NAME, MSISDN TRANSACTIONS

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

CM, SA - MERCHANT I 829882904 75

CM, SA - II MERCHANT 827102931 48

Any ideas?

TXS so you can help

Hello

One way is a Request of Top - N , like this

WITH got_r_num AS

(

SELECT x *- or list columns you want

Rank () OVER (PARTITION BY display_name

Operations ORDER BY DESC

) AS r_num

FROM table_x

-WHERE... - If you need any filtering, put it here

)

SELECT *- or the list of all columns except r_num

OF got_r_num

WHERE r_num = 1

;

I hope that answers your question.
If not, post a small example data (CREATE TABLE and only relevant columns, INSERT statements)
Point where the above query is to produce erroneous results, and explain, using specific examples, how you get the right results in these places.
Always say what version of Oracle you are using (for example, 11.2.0.2.0).

See the FAQ forum: https://forums.oracle.com/message/9362002#9362002

Tags: Database

Similar Questions

  • How to establish links of Labview with SQL server database Toolkit

    I'm a database newbie, but I have to use MS SQL server (2008) to store my data. I am well equipped with all the features of Labview, don't know how to use it properly. I now complete development, including the toolbox database. My latest version of labview is 8.6.1. Side material, I have cFP2220 and many modules of differnet kind.

    Here is a useful link that I found on the web:

    1. I got the database creation procedure (pdf file) to link the udl.

    http://decibel.NI.com/content/docs/doc-4602

    It gives a step-by-step login procedure to MS Access, and I'm able to save data to MS Access with the database Toolbox. However, I could not understand how to establish a chain of connection or udl to SQL server. In other words, I hope someone can explain in detail what is the procedure to set up such a link.

    2. I learned about the forum that there is a LabSQL, but it takes some knowledge of SQL statement. I would walk away from him, as I am not familiar with SQL.

    3. the VI I used for the recording of data in DB are very similar to "Create database Table.vi" found in the sample.

    In short, I think that I just need someone who has experience with the connection to the server SQL with Labview to show me the steps to link to SQL.

    Thank you very much

    You may not create a database in SQL Server using the control panel ODBC or a UDL. You must create a database by using SQL Server tools. (In fact, you can use SQL statements to create a database, which is what's really going on by using SQL Server tools. However, I don't know if the database Toolbox has the screws required to send these types of SQL statements.). Once you have created the database you can create tables using SQL Server tools, or you can use the screw of toolbox database.

    You try to run SQL Server on your computer? SQL Server is usually running on a server. You try to use SQL Server Express?

    Assuming that you have SQL Server running and a database has been created, then here are the steps needed to create a UDL to connect:

    1. In Windows Explorer, create a text file and rename the text file so that there a .udl extension (like this PDF).
    2. Double-click the UDL file.
    3. Change to the tab 'supplier '.
    4. Select 'Microsoft OLE DB for SQL Server provider'.
    5. Click on the ' next > ' button. It changes you to the tab 'connection '.
    6. In the drop-down menu, select your SQL Server. If it is not listed, try clicking on the Refresh"" button. If this does not meet the list, then you will need to enter manually.
    7. In the section "#2" specify the authentication method and credentials, if necessary, to connect to SQL Server.
    8. In the section "#3" specify the database that will be used, which is the one that you created earlier using the SQL Server tools. NOT SELECT THE MASTER DATABASE. If you do, you will completely screw up your installation of SQL Server.
    9. Click "Test connection" to verify that you can connect to SQL Server.
  • How to order a tree balanced with SQL hierarchical queries

    by searching the forum I found this

    Re: Generate tree balanced with SQL hierarchical queries

    is there a way I can order this tree in alphabetical order so that the result looks like

    LEVEL INDENTED_ENAME
    ---------- --------------------
    1 KING BED
    2 BLAKE
    3 ALLEN
    3 JAMES
    MARTIN 3
    3 TURNER
    WARD 3
    2 CLARK
    3 MILLER
    2 JONES
    3 FORD
    4 SMITH
    3 SCOTT
    4 ADAMS

    -the original query-

    SELECT THE LEVEL
    , LPAD (' ', 3 * LEVEL) | Ename AS indented_ename
    FROM scott.emp
    START WITH mgr IS NULL
    CONNECT BY PRIOR empno = mgr
    ;

    LEVEL INDENTED_ENAME
    ---------- --------------------
    1 KING BED
    2 JONES
    3 SCOTT
    4 ADAMS
    3 FORD
    4 SMITH
    2 BLAKE
    3 ALLEN
    WARD 3
    MARTIN 3
    3 TURNER
    3 JAMES
    2 CLARK
    3 MILLER

    Hello

    Bodin wrote:
    Hi Frank, I can order it selectively depending on the level, which means that only siblings stopped at third level, but rest of the brothers and sisters remain Nations United ordered

    It's actually quite difficult. You can "ORDER of brothers and SŒURS BY CASE... ', like this:

    SELECT  LEVEL
    ,      LPAD (' ', 3 * LEVEL) || ename     AS indented_ename
    FROM      scott.emp
    START WITH        mgr     IS NULL
    CONNECT BY         mgr      = PRIOR empno
    ORDER SIBLINGS BY  CASE
                   WHEN  job = 'MANAGER'  THEN  ename
                                              ELSE  NULL
                 END
    ;
    

    In this case to get desired results in table scott.emp, as the lines are LEVEL = 2 if and only if use = "MANAGER".
    But if you reference LEVEL in the CASE expression (for example, if you replace ' job = 'MANAGER' ' with "2 LEVEL =" above "), then you will get the error" ORA-00976: LEVEL, PRIOR or ROWNUM not allowed here. "
    The best way I can think to do exactly what you asked is to do 2 CONNECT BY queries; one just to get the LEVEL and the other for the brothers and SŒURS ORDER BY:
    {code}
    WITH got_lvl AS
    (
    SELECT LEVEL AS lvl
    Bishop
    empno
    ename
    FROM scott.emp
    START WITH mgr IS NULL
    CONNECT BY PRIOR empno = mgr
    )
    SELECT lvl
    , LPAD (' ', 3 * LEVEL) | Ename AS indented_ename
    OF got_lvl
    START WITH mgr IS NULL
    CONNECT BY PRIOR empno = mgr
    BROTHERS AND SŒURS OF ORDER OF CASES
    ONCE lvl = 2 THEN ename
    ANOTHER NULL
    END
    ;
    {code}
    Why you can't simply "Brothers and SŒURS of ORDER BY ename" at all levels? If all you care is the order of the items of LEVEL = 2, then this is probably the most effective and simplest way. It really hurt anything if nodes on levels 3, 4, 5,... are in order, too?

    Here's something you can do if you want to order by different unique things to different levels:
    {code}
    WITH got_sort_key AS
    (
    SELECT LEVEL AS lvl
    , LPAD (' ', 3 * LEVEL) | Ename AS indented_ename
    empno
    SYS_CONNECT_BY_PATH (LPAD (CASE
    WHEN LEVEL = 2
    THEN ename
    Of OTHER TO_CHAR (empno)
    END
    10
    )
    , ','
    ) AS sort_key
    FROM scott.emp
    START WITH mgr IS NULL
    CONNECT BY PRIOR empno = mgr
    )
    SELECT lvl
    indented_ename
    empno
    OF got_sort_key
    ORDER BY sort_key
    ;
    {code}
    However, all possible values of the CASE expression must uniquely identify the node; otherwise, the output won't necessarily hierarchical order. You can assign arbitrary unique IDS to the lines (using the ROW_NUMBER analytic function, for example), but that requires another subquery and is also complex and perhaps as ineffective as the solution above with 2 garages CONNECT.

  • How to extract several versions of the asset in Photoshop CC 2015? The + icon disappeared in 2015 CC?

    Using Photoshop | Extract assets

    1. To retrieve multiple versions of assets, click on the icon next in the dialog box extract assets assets +. You can specify different format, quality and scale of parameters for each asset.

    But the + icon next to assets in the Extract assets dialog disappeared in Photoshop CC 2015. Please see the pictures below.


    Captura de Tela 2015-06-16 às 16.15.12.png



    Photoshop CC x Photoshop CC 2014 2015

    Captura de Tela 2015-06-16 às 16.16.19.png

    Can someone help me?

    Unfortunately the GUI for setting this place has been withdrawn, "from the version 2015 Photoshop CC, extracted active feature is is no longer available.

    .. but the good news are, you can always configure the active generation manually.

    You can check some old settings to export manually here:
    Using Photoshop | Generate the layers image assets

    But here's a quick reminder on how to get there:

    Name the layers/groups you want exported with an extension.

    "Select - use .png '.

    'Group.png '.

    Create a new empty layer to set your options. Depending on how you name the layers, you can change the size, add names to files, set the jpg quality, all sorts of settings for various extensions. The example below will display them 100% and a second series to 200% with a @2 annex x.

    «by default, 100%, 200% @2 x»

    "Select - use .png '.

    'Group.png '.

    Then you just turn it on
    File > generate > Image assets

    It will create a folder in the location of the DSP with the property that you specified.

    Filename.PSD

    Filename-assets

    "Select - use .png '.
    '[email protected] '.
    'Group.png '.
    '[email protected] '.

    If you do not turn off your generation, it will continue to re-export and update files automatically as you make changes to the document.

  • How to create several contours growing with every distance equal to the original form?

    outlines.png

    Here is a very simple example... It works with a circle or a square, obviously because he has the same height and width. The problem is when you have irregular shapes (or in this case, an oval). I know I've seen solutions to this in the past, but I can not just think how Word of this question and find them.

    I know that you can create several shots of an object in the appearance palette, but I'm looking for something more effective than simply STROKE color > white line > race color > white race > etc.

    Some examples of the kind of effect I'm looking for.

    FRSH-SLCTS-Captain-Murphy-DUALITY-494x494.jpg

    captain-murphy.jpg

    Any help would be greatly appreciated.

    You must use the path of the Offset. Object > path > offset path. Use negative numbers to go inside a form existing, positive to go outside.

    [signature removed by the host of the forum - advertising is prohibited]

  • How to get the Max value with other columns data also.

    Suppose that a query is covered with the data as

    Time of ID
    01 07/12/2014
    02 07/05/2014
    03 16/07/2014
    04 07/07/2014

    I need to get the ID and time to time max.
    that is, should I get
    Time of ID
    03 16/07/2014

    To do this, I wrote a query that gives me necessary data. But I thought that's the best way?
    Is it an effective way to get this data?
    My query that returns the data required is:

    SELECT ID, MAX_DT FROM
    (
    Select 'DUMMY', ID, TIME1, MAX (TIME1) OVER (PARTITION 'DUMMY') AS MAX_DT FROM TAB1
    WHERE ID IN (BLAH BLAH)
    )
    WHERE MAX_DT = (EDT) 1

    Frank mentioned links


    WITH test_data (id, time) LIKE)

    SELECT 01, to_date('2014/07/12','yyyy-mm-dd') FROM dual

    UNION ALL

    SELECT 02, to_date('2014/07/16','yyyy-mm-dd') FROM dual

    UNION ALL

    SELECT 03, to_date('2014/07/16','yyyy-mm-dd') FROM dual

    UNION ALL

    SELECT 04, to_date('2014/07/07','yyyy-mm-dd') FROM dual

    )

    SELECT id, time

    go (select id,

    time,

    Max (Time) on latest_time (order by time lines between unbounded preceding and following unbounded)

    of test_data

    )

    where time = latest_time

    ID TIME
    3 16/07/2014
    2 16/07/2014

    Concerning

    Etbin

  • How to read several channels simultaneously with a minimum

    Hi all

    Please see the attached file. In fact, this is a simplified example of my real application, I didn't understand the second half to reduce the complexity.

    As demonstrated, I have two entries of analago I need to read (position and acceleration) with a SPECIFIC requirement which is:

    At the same time, I make some decisions based on data more recently acquired in the "timed loop. The decision part is not included in this vi. for simplicity. But the fact is that I just need the most recent data (as well as online) make a kind of decisions.

    Everything seems fine and it seems that I collect data in a way desired interval of 1msec. BUT I just discovered that the data I read (in the timed loop) are the most recent one compare is not to the real sensors. In other words, there is a delay in the acquisition process. The value in the timed loop is like 100 msec delayed the release of real sensor, which is generated by the sensor and acquired by DAQ card.

    This problem makes my decision making part of constantly decide according to the before value of 100 msec. Unfortunately, it's terrible to my request, i.e. it is an intolerable delay to the process.

    Are my settings of data acquisition as samples per channel, the number of samples per channel or right of sampling rate? I appreciate if someone can help me with this application. I just need to collect data at 1 kHz, as close as possible in real-time (online) or with a minimum delay, not 100 msec.

    Thank you.


  • How to move several scrollbars field with a scroll bar

    Hello

    Does anyone know if there is a property node available where I can use the axis scroll bar x on a plot to control several bars scroll to the category axis at the same time?  I have three plots and I want all scroll to the time where I drag the scroll bar on one... I've been going through the nodes of property but fails to do so.

    Thank you very much!

    I think that the only way to do this is to monitor the range of the scale X, as the beginning of the beach. If the user clicks the scroll bar, changes in range if you can it detect this way. You can then set the scale on the other graphics to match.

  • How to create multiple tables with SQL commands

    Hi, first of all, is it possible to create a table and then one more both with SQL commands?
    because I tried to do this in the following way
    Example:
    CREATE TABLE 'HB_Product')
    "productId" number 4 NOT NULL.
    "productName" VARCHAR2 (20) NOT NULL,
    "prodPricePerTon" NUMBER (10,2).
    "HB_Product_PK" PRIMARY KEY CONSTRAINT ("productId")
    )
    /
    CREATE TABLE 'HB_Operations')
    "orderNo" NUMBER (5) NOT NULL,
    'lineNo' number 4 NOT NULL.
    "billNo" NUMBER (10) NOT NULL,
    'actions' VARCHAR2 (15).
    'place' VARCHAR2 (15).
    "actDate" DATE NOT NULL,
    "totWeight" NUMBER (6.3).
    'HB_Operations_PK' CONSTRAINT PRIMARY KEY ('lineNo')
    )
    /

    I copied some of the syntax for creating the table object browser, but I preffer to use my own sql.
    It gives me an error "Missing or option not valid."

    Can someone explain to me how to do it properly, or why it is not possible?

    Best regards from Stan!

    862377 wrote:
    so you're saying I can't do several tables at the same time?

    Yes... Well,... not this way

    You can do this way

    create schema authorization alex
    CREATE TABLE "HB_Product" (
    "productId"    NUMBER(4) NOT NULL,
    "productName"    VARCHAR2(20) NOT NULL,
    "prodPricePerTon"    NUMBER(10,2),
    CONSTRAINT "HB_Product_PK" PRIMARY KEY ("productId")
    )
    CREATE TABLE "HB_Operations" (
    "orderNo"    NUMBER(5) NOT NULL,
    "lineNo"    NUMBER(4) NOT NULL,
    "billNo"    NUMBER(10) NOT NULL,
    "actions"    VARCHAR2(15),
    "place"    VARCHAR2(15),
    "actDate"    DATE NOT NULL,
    "totWeight"    NUMBER(6,3),
    CONSTRAINT "HB_Operations_PK" PRIMARY KEY ("lineNo")
    )
    /
    

    The question is: why do you want to create "at the same time? What is the harm in creating one after the other?

    some tips (maybe not desired):
    do not use quotation marks in your statement, this will create column names and the table out.

  • How can I stop Outlook Express sends several empty messages with attachments

    How can I stop Outlook Express sends several empty messages with attachments

    Not a lot of information, but CrystalBall © says:
     
    Tools | Accounts | Mail | Properties | Advanced. Uncheck the box: "Break apart messages...". ».
  • How to find assets to a project of the BCC with SQL

    Hello.

    I would like to know how to find assets to a project of the BCC with SQL.

    Thank you.

    Hello.

    You can try this.


    select * from dcs_product where workspace_id in ( Select avm_devline id where the name of (select Workspace for epub_project where display_name = "${name_of_project}"));

    For each version of an asset is recorded the id workspace on the workspace_idfield. This workspace is related to the project in the field name and the workspace field in table epub_projecttable avm_devline .


    But this query must be performed from the active table. Example: Product = dcs_product, sku = dcs_sku, class = dcs_category and so on.

    Thank you rtreto for the help.

  • How do I get the data of "Regulatory BOM" Formulation with SQL query output

    Hello

    We would like to implement a State of BiPublisher that displays "Regulation BOM" (wording-> click on TAB Formulation on exit Popup-> TAB Composition) information table.

    How could get us this information with an SQL query?

    Thank you

    Annarosa

    Hi, given 'Regulatory BOM' output of the Formulation are more complicated than expected. Attached is an example. You can test and make the appropriate changes to your report.

  • How to execute a stored procedure on Sybase with SQL Developer

    We have accessed Sybase 15 with SQL developer.

    We can see the data in the table, if we do not, run the stored procedure (for instance sp_who) developed on Sybase.

    Could you tell me how we execute the stored procedure on Sybase with SQL Developer Sybase?

    Thank you

    Shige

    We will not intended to be a Sybase ASE customer.

    But

    A SQL Developer... @dermotoneill: Workheet advice

  • How to treat several Photos with removal of Haze Auto

    Win7 64 bit

    Photoshop Elements 14

    Hello:

    How to treat several photos with removal of haze self at the same time? And how can I process several photos with auto shake reduction at the same time?

    If this can be done with actions, is there an action that can be downloaded to achieve?

    Thank you

    r398tow wrote:

    Win7 64 bit

    Photoshop Elements 14

    Hello:

    How to treat several photos with removal of haze self at the same time? And how can I process several photos with auto shake reduction at the same time?

    If this can be done with actions, is there an action that can be downloaded to achieve?

    Thank you

    Unfortunately, you can only batch with commands in the option "treat multiple files" of the editor or the 'Export' one in the Organizer. Action would be able to combine several orders for a single file, but do not use the command given on a lot. You would need a script for this.

    The two new orders to 14 elements (haze removal and shake reduction) can be very effective, but they can also produce strange artifacts... Their use in the batch may be undesirable.

    I recommend the following solution to improve lots of files needing to increase the local contrast:

    If you work with raw files, open a small batch of files from the Organizer in the ACR module. Use the cursor to 'clarity' to all files in the batch and add some sharpness.

    If you work with JPEG files, use the editor and choose "open in camera raw" option for your batch chosen files from the file.

    Who should provide a good improvement to most of your files. You can use two new orders than in the pictures with the specific defects:

    -shake (common with telephoto lenses) removal

    -mist removal (not only haze, but images softened with "flare")

  • How to connect my APEX with SQL Developer workspace?

    Hi all

    I am a new user of Oracle Apex. Is there a way to connect to my workspace created to http://apex.oracle.com/pls/apex with SQL Developer. If so, then let me know how. If someone has done successfully then please help me.

    Thank you

    Gerard

    Hi Gerard,

    It is not possible to do this on apex.oracle.com.

    Joel

Maybe you are looking for