Get line with max value
Hi allI have a table
Amount Line_num
1 10
2 20
3 30
create table Test (number line_num, quantity number);
Insert into test values (1,10);
Insert into test values (2.20).
Insert into test values (3.30);
I need to get the line number that has a maximum amount.
Help, please.
Thank you
Anatoliy
select
max(line_num) keep (dense_rank last order by amount) m
from test
M
3
concerning
Tags: Database
Similar Questions
-
How to display the line empty as a line with null values
Hi all
Pls advise me if it is possible to use a single query statement to display
Empty row (i.e. not a single return line) as a line with null values.
For example,.
Select the names of names_mst whose name = "sgasfgs".
Result:
Names of
=====
< null >Hello
If you desire to join external to double, as shown below, you still get at least a line of productionSELECT nm.names FROM dual LEFT OUTER JOIN names_mst nm ON nm.name='sgasfgs';
-
Updated several lines with different values
Hello!
I have a problem. I need to update more than 1000 lines with different values. How can I do?
For exsample I have table:
ID; color, date,
1 red
2 green
3 white
I need to update the date field.
Update table
Set date = '01.02.03'
where id = 1
Update table
Set date = '01.03.03'
where id = 2
Maybe it's how to update multiple rows in a single request?
Sorry for my bad English.
Thank you!Hello
You can try this
UPDATE TABLE SET DATE = CASE WHEN ID = 1 THEN TO_DATE('01-02-03','DD-MM-RR') WHEN ID = 2 THEN TO_DATE('01-03-03','DD-MM-RR') END
see you soon
VT
-
Pulling on the first line with a value of repetition
Hello
We use the Oracle 11.1.
We have a table of postal codes.
We have several lines for each zip code because we have different areas that use the same zip code.
We want to reduce the lines of a line by zip code. But they said use they want to keep the fields that differ (neighborhood of the exodus).
Then they said "Just take the first value of each."
This code reduces the postcodes of a line by postal code, but as you can see I replaced the field with the name of the field values.
How should I take either one record per postal code with the first value in these fields orSELECT distinct ZIPCODE, CITY, STATE, COUNTY, AREACODE, 'CITYTYPE', CITYALIASABBREVIATION, 'CITYALIASNAME', LATITUDE, LONGITUDE, TIMEZONE, ELEVATION, COUNTYFIPS, DAYLIGHTSAVING, PREFERREDLASTLINEKEY, CLASSIFICATIONCODE, MULTICOUNTY, STATEFIPS, 'CITYSTATEKEY', 'CITYALIASCODE', 'PRIMARYRECORD', CITYMIXEDCASE, 'CITYALIASMIXEDCASE', STATEANSI, COUNTYANSI FROM zip_code GROUP BY ZIPCODE, CITY, STATE, COUNTY, AREACODE, CITYTYPE, CITYALIASABBREVIATION, LATITUDE, LONGITUDE, TIMEZONE, ELEVATION, COUNTYFIPS, DAYLIGHTSAVING, PREFERREDLASTLINEKEY, CLASSIFICATIONCODE, MULTICOUNTY, STATEFIPS, CITYALIASCODE, PRIMARYRECORD, CITYMIXEDCASE, STATEANSI, COUNTYANSI order by zipcode;
How should I take the first record for each zip code?
either way works for me.
Thank youHello
This is called a Query Top - N , and this is a way to do it:
WITH got_r_num AS ( SELECT z.* , ROW_NUMBER () OVER ( PARTITION BY zipcode ORDER BY city , ... -- add tie-breakers here ) AS r_num FROM zip_code ) SELECT * -- or list all columns except r_num FROM got_r_num WHERE r_num = 1 ;
You can simply use MIN or MAX on the columns, as the line with the name of the minimum city do not lowest have area code or the longitude. The above method preserves the first line of each zip code intact, where the 'first': the first in order of aphabetic by the name of the city. If it is not unique, then you may want breakage to the analytical ORDER BY clause.
If you are deleting rows, you can use this in a NOT IN subquery. If you copy lines to a new table, you can use the query above in an INSERT statement.
Published by: Frank Kulash, March 18, 2011 12:40
I just see Polywog response:
Pollywog wrote:
You can use the rank or rownumber function...If I understand the problem, you don't want to use RANK in this particular case. When there is equality, GRADE will assign 1 to all the contenders. I think the whole point of this thread is that you exactly want a #1 in each zip code, which is what ROW_NUMBER, but not RANK, guarantees.
-
Retrun separate lines with duplicate values
Hello
I have the columns id, addr1, addr2, city and State of coding. I need to know all the coding IDS that have the same addresses and at the same time filter out the same side of the id of the request.
For example:
acctid addr1, addr2 City State
WEF 1 101 101 sd
1 101 wef sd
WEF 2 101 101 sd
WEF 3 101 101 sd
DC 4 102 102 homeless
From the above data, I want to get filter tier 4 and get lines 1, 2 and 3. How to achieve with a sql query
Thank you
Arch
Wrong forum!
This forum is ONLY for sql developer questions.
Please mark the thread ANSWERED and repost it in Sql and PL/SQL forum.
-
Help line with MAX Date selection
The data returned by my query currently looks like this.
10 100 A 29 FEBRUARY 12
11 101 OCTOBER 16, 12 B
12 102 B 5 DECEMBER 12
13 103 C 23 JANUARY 13
When the data in the third column is duplicated, I want to only return the line with the most recent date in the 4th column (in this case row 3).
So what I really want is the following.
10 100 A 29 FEBRUARY 12
12 102 B 5 DECEMBER 12
13 103 C 23 JANUARY 13
Any help would be greatly appreciated.Thank you
Mark
Here's a way...
SQL > ed
A written file afiedt.buf1 with t as (select 10 as the id, 100 such as seq, 'A' as the grp, date '' 2012-02-29 as dt of union double all the)
2. Select 11, 101, 'B', date '' 2012-10-16 of all the double union
3. Select 12, 102, 'B', date '' 2012-12-05 Union double all the
4. Select 13, 103, 'C', date "double ' 2013-01-23)
5 --
6 select max (id) keep (dense_rank of the first order by dt desc) as id
7, max (seq) keep (dense_rank of the first order by dt desc) as seq
8, grp
9, max (dt)
10 t
11 * grp group
SQL > /.ID SEQ G MAX (DT)
---------- ---------- - --------------------
10 100 WAS FEBRUARY 29, 2012 00:00:00
12 102 B 5 DECEMBER 2012 00:00:00
13 103 C 23 JANUARY 2013 00:00:00 -
Add filter slot table form to show the lines with null values
Hello
I have a tabular presentation where we need to add a filter with two values (selection list) so that if one of the columns in a table (column1) is zero, then I need to display all records where column1 is null.
I was wondering how do I put this in the Source of tabular forms where condition. This filter has only two values,
All the
NULL for the error
So when the user selects all, then all the records in the table are shown
If the user selects 'Value Null in error', while the records where Column1 is null will be shown
For example
If the user selects, thencolumn1 column2 A B 1 C 3 D
all four files will show up. Else, only the first and the second will be returned.
Thank youHi, Ryan.
Try a static LOV like this
STATIC2:;,--- All ---;--- All ---
and a Where clause, like this
where column1 is null or :p1_filter like '%%'
Jeff
-
Hi Forum,
need help with my problem of named. I need to select distinct
MNR
to the maximum value ofWBZNEW
.It is a part of my table
MNR, WBZNEW, LZ, resource
11210009, 25.20, 7000381
11210009, 20.15, 7000658
11210011, 20.15, 7000359
11210011, 20.15, 7009123
11210011, 20.15, 7001327
11210012, 20.15, 7001327
11210012, 20.15, 7009123
11210018, 40.35, 7000324
11210018, 45.40, 7000381
11210027, 20.15, 7000324
11210027, 30.25, 7001683
11210027, 20.15, 7000378
Thanks for your help
Heiko
Try this
Select MNR, max (wbznew)
of table_nme
Group by MNR;
-
Get PortGroup with DvUplinks value is not used
Would hi be possible to report on trade within a same distributed switch who have unused value by using a script powercli dvUplinks?
The question is not 100% clear to me, but I guess you want to see the VDS with unused Uplink ports.
Then you can do
Get-VDSwitch |
where {}
$uplinkPg = get - see $vds. ExtensionData.Portgroup | where {$_.} Tag.Key - match "UPLINKPG"}
$uplinkPG.Config.NumPorts - only $uplinkPG.PortKeys.Count
} |
Select Name,
@{N = "Uplink Ports"; {E = {$uplinkPG.config.NumPorts}}.
@{N = "Ports Uplink used"; {E = {$uplinkPG.PortKeys.Count}}
-
How to get lines with English letters at the end of race
Hi all
Examples of data include:
create table test_app(application_no number, net_code number,branch varchar2(40)); insert into test_app values(1001,01,'operations') insert into test_app values(1001,02,'production'); insert into test_app values(1001,03,'testing') insert into test_app values(1002,01,'power coding'); insert into test_app values(1002,02,'testing') insert into test_app values(1002,03,'export'); insert into test_app values(1002,03,'operations');
SQL> select*from test_app 2 where application_no=1001; APPLICATION_NO NET_CODE BRANCH -------------- ---------- ----------- 1001 1 operations 1001 2 production 1001 3 testing
But my real need is delivered as follows:1 select*from test_app 2* where application_no=1002 SQL> APPLICATION_NO NET_CODE BRANCH -------------- ---------- -------------- 1002 1 power coding 1002 2 testing 1002 3 export 1002 3 operations
If an application having more then a result lines then
I must add A, B, C, D... up to the total number of rows in the result set.
Surely it will not exceed more then 26 ranks (will not exceed 'Z');
the result should is:
ask any = 1001
DIRECTORATE GENERAL OF THE NET_CODE OF THE APPLICATION_NO
-------------- ---------- -----------
1001 operations 1
2-1001 production_A
1001 3 testing_B
ask any = 1002
DIRECTORATE GENERAL OF THE NET_CODE OF THE APPLICATION_NO
-------------- ---------- --------------
1002 1 power coding
1002 2 testing_A
3 1002 export_B
3 1002 operations_C
If we have 10 lines to the appication = 1002;
DIRECTORATE GENERAL OF THE NET_CODE OF THE APPLICATION_NO
-------------- ---------- --------------
1002 1 power coding
1002 2 testing_A
3 1002 export_B
3 1002 operations_C
.... ..........._I
Note: first line should add with no letters. Add letters with the second row.
How to achieve this result. Please help me...
Published by: roots on 6 March 2012 09:14select application_no, net_code, branch || case when row_number() over(partition by application_no order by net_code,branch) > 1 then '_' || chr(ascii('A') + row_number() over(partition by application_no order by net_code,branch) - 2) end branch from test_app order by application_no, net_code, branch / APPLICATION_NO NET_CODE BRANCH -------------- ---------- ----------------- 1001 1 operations 1001 2 production_A 1001 3 testing_B 1002 1 power coding 1002 2 testing_A 1002 3 export_B 1002 3 operations_C 7 rows selected. SQL>
SY.
-
Ridge line with default values
Hi friends I am using JDeveloper 11.1.1.3.I want to create a new line in a table .but this line must have some default values. As an attribute username, still need to show a default name. I need to write the ViewImpl method.According to [url http://download.oracle.com/docs/cd/E17904_01/apirefs.1111/e10653/oracle/jbo/server/ViewRowImpl.html#create (oracle.jbo.AttributeList documentation)] the, really want to do this by overriding the method create of the ViewRowImpl class (that is, assuming that in the VO is the right place).
The Fusion developer [url http://download.oracle.com/docs/cd/E17904_01/web.1111/b31974/bcrules.htm#sthref794] Guide also shows you how to proceed at the level of the OS
John
-
generate the view in line with the values of the 'sequence' 0.36
I want my query to join inline view that has values of 0.36, what is the best way to create this inline-view?
My initial solution would be:
I want to write the query that returns the same values as this query, I showed.SELECT LEVEL RESULT FROM Dual CONNECT BY LEVEL < 37 union select 0 from dual order by 1
CharlesRoos wrote:
I want my query to join inline view that has values of 0.36, what is the best way to create this inline-view?
My initial solution would be:SELECT LEVEL RESULT FROM Dual CONNECT BY LEVEL < 37 union select 0 from dual order by 1
I want to write the query that returns the same values as this query, I showed.
SELECT (LEVEL - 1) RESULT FROM Dual CONNECT BY LEVEL <= 37 ;
Published by: user503699 on October 29, 2010 14:20
-
How to return a single LINE with Multiple value separated by a colon in a SQL query
Hello
I have a SQL, as shown.
I want to mofidfy this query, so that it should return me departments with colon delimeted list in a ROW.select deptno from dept
Thank you10:20:30:40.......
Deepak
-
Get the max value with other areas
Hi all
I have a table as below
Value name
- - - - - - - - - - - - - - - -
A1 5
A3 10
A2 7
A2 9
A1 10
What I get is the max (Value) and with the consolidation of its name
Value name
- - - - - - - - -
A2 16
Thank you
Alex
Published by: user8606416 on June 1, 2011 10:17
Published by: user8606416 on June 1, 2011 10:26Depends on how you feel on one of the links of:
SELECT name, value FROM (SELECT name, SUM(value) FROM table GROUP BY name ORDER BY 2 DESC) WHERE rownum = 1 SELECT name, SUM(value) FROM table GROUP BY name HAVING SUM(value) >= ALL (SELECT SUM(value) FROM table GROUP BY name)
among many other methods. The first takes a single arbitrary registration in the case of a tie, and the second shows all the related records.
John
-
Problem with getting communication with old instrument GPIB-ENET/100
Hello!
I'm trying to get my program in VB.net to communicate with an older instrument (Infratek 305 A, measure of power) via a GPIB-ENET/100 device.
The manual of the instrument does not say what GPIB standard, it supports, but the instrument is detected by the measurement and Automation Explorer.
Detected by that I mean that MAE has detected an instrument located on the right GPIB address, but indicated identification is the output measure instrument string
instead of the name of instrument (as shown for some more recent instruments of Agilent).
When I run my application, I followed the communication with NISpy.
Configuration of the device seems to work and I present only once in the program.
The problem is reading data from the instrument. Whenever I read the data, I get a correct string of the instrument. But the problem is
I get the same data in two consecutive and all readings first after that I get new data and also these new data are received in two consecutive readings.
According to the manual of the instrument the instrument generates the data as follows:
"A row of data ends with CRLF. The instrument can send multiple rows of data. "When all of the data transfer is complete the EOI (end or identify) is sent.
My endpoint settings are:
Send EOI to write complete: YES
Terminate read on EOS: No.
EOS byte: 2
8 bit EOS compare: YES
Define EOI with EOS on write: No.
How can I configure the GPIB-ENET/100 to work with my instrument?
Here are som NISpy logs:
# Configuration #.
61 ibwrt(UD3, "C0C2C4C8..", 10 (0xA))
PID: 0x0000113C Thread ID: 0x000008B4
Departure time: 13:54:43.671 call duration 00:00:00.079
ibsta: 0 x 100 iberr: 0 ibcntl: 10 (0xa)62 ThreadIbcntl()
PID: 0x0000113C Thread ID: 0x000008B4
Departure time: 13:54:43.750 call duration 00:00:00.000
ibsta: 0 x 100 iberr: 0 ibcntl: 10 (0xa)63 ibwrt(UD3, "K0K3K5K9..", 10 (0xA))
PID: 0x0000113C Thread ID: 0x000008B4
Departure time: 13:54:43.765 call duration 00:00:00.125
ibsta: 0 x 100 iberr: 0 ibcntl: 10 (0xa)64 ThreadIbcntl()
PID: 0x0000113C Thread ID: 0x000008B4
Departure time: 13:54:43.890 call duration 00:00:00.000
ibsta: 0 x 100 iberr: 0 ibcntl: 10 (0xa)65 ibwrt(UD3, "F14F18F24..", 11 (0xB))
PID: 0x0000113C Thread ID: 0x000008B4
Departure time: 13:54:43.890 call duration 00:00:09.250
ibsta: 0 x 100 iberr: 0 ibcntl: 11 (0xb)66 ThreadIbcntl()
PID: 0x0000113C Thread ID: 0x000008B4
Departure time: 13:54:53.140 call duration 00:00:00.000
ibsta: 0 x 100 iberr: 0 ibcntl: 11 (0xb)### LU ###
437 ibrd(UD3, "*AC/1.0A480V/...", 1024 (0x400))
PID: 0x0000113C Thread ID: 0x000008B4
Departure time: 13:58:52.484 call duration 00:00:00.094
ibsta: 0 x 2100 iberr: 0 ibcntl: 225 (0xe1)438 ThreadIbcntl()
PID: 0x0000113C Thread ID: 0x000008B4
Departure time: 13:58:52.578 call duration 00:00:00.000
ibsta: 0 x 2100 iberr: 0 ibcntl: 225 (0xe1)439 ThreadIbcntl()
PID: 0x0000113C Thread ID: 0x000008B4
Departure time: 13:58:52.578 call duration 00:00:00.000
ibsta: 0 x 2100 iberr: 0 ibcntl: 225 (0xe1)Hello!
I don't have the opportunity to test with other controllers.
However, I found a solution to my problem.
The instrument should output 4 lines of data.
L1 - line with comments
L2 - line with current values
L3 - line with the values of voltage
L4 - line with power values
The first line of the reading stops the instrument of implementation of additional measures.
The measurements in the instrument began reading the last line of data (L4)
The problem was that the instrument for a reason any also released a fifth line, which was empty.
Read this line 5' th stopped the instrument again.
By configuring the HW to finish reading on EOS, with EOS PMQS, the value byte, I could read the
buffer of the instrument with a line output instead. This way I could read just L1 - L4
and the instrument could work again.
Next time I should read data from the Instr. first of all, I would like to read the empty line, then
L1 - L4.
Why the outputs Instr. an additional empty line will be left not resolved.
My problem is solved.
Maybe you are looking for
-
The computer is not download automatic updates when she stops to download
-
Office disappeared. Page is black
After the removal of the malware using Malwarebytes, the office is now black; No file list. Help!
-
Clone of another hard disk Vista system
I works under Vista 32 bit on 250GBs hard drive (C :) and now want to move on to bigger hard drive.) After that I can reformat the old hdd as a hard drive for data.So, how do I clone or copy Vista systems include directory, adjustment system, registr
-
How to connect a second router WRT54G
I can't get a signal through my entire House so I bought a second router WRT54G, running that the Setup disk affects only the first router so how do the other work?
-
Original title: update of security for microsoft visual C++ 2005 Service Pack 1 (KB2467175) My settings are for me to download the updates myself, so when I noticed several updates were the same I checked and they are the same in 8 separate downloads