connect max value
Here's what I'm trying to get:
Get the max c_event_id for each event_cd and max and then p_event_id and then enter the values of tot_time, tot_time_ut, in_dttm, out_dttm
Table:
create table temp
tant_que)
SELECT
(SELECT DOUBLE 111111) PRSN_ID
, Event (SELECT "PACU Out Date_Time' FROM DUAL)
, (SELECT 5790707237 FROM DUAL) EVENT_ID
c_event_id (select 5790707236 double)
, (by selecting 5790707235 in double) P_event_id
, (SELECT 35451064 FROM DUAL) EVENT_CD
TOT_TIME (1700 SELECT FROM DUAL)
TOT_TIME_UT (SELECT ' MIN' TO DOUBLE)
, (SELECT NOVEMBER 25, 2014 19:15 ' FROM DUAL) IN_DTTM
, (SELECT NOVEMBER 25, 2014 19:15 ' FROM DUAL) OUT_DTTM
OF THE DOUBLE
);
TRUNCATE TABLE temp
INSERT INTO temp
(PRSN_ID, events, EVENT_ID, c_event_id, P_event_id, EVENT_CD, TOT_TIME, TOT_TIME_UT, IN_DTTM, OUT_DTTM)
VALUES
(88346837, ' PACU Date_Time in ", 5790707237, 5790707236, 5790707235, 35451064,0,' ', November 25, 2014 19:15 ',' ');
INSERT INTO temp
(PRSN_ID, events, EVENT_ID, c_event_id, P_event_id, EVENT_CD, TOT_TIME, TOT_TIME_UT, IN_DTTM, OUT_DTTM)
VALUES
(88346837, ' PACU Date_Time in ", 5790707712, 5790707711, 5790707710, 35451064,0,' ', November 25, 2014 19:15 ',' ');
INSERT INTO temp
(PRSN_ID, events, EVENT_ID, c_event_id, P_event_id, EVENT_CD, TOT_TIME, TOT_TIME_UT, IN_DTTM, OUT_DTTM)
VALUES
(88346837, 'PACU Out Date_Time', 5791208701, 5791208700, 5790707235, 35451075,0, "","", December 31, 2014 22:05 ');
INSERT INTO temp
(PRSN_ID, events, EVENT_ID, c_event_id, P_event_id, EVENT_CD, TOT_TIME, TOT_TIME_UT, IN_DTTM, OUT_DTTM)
VALUES
(88346837, 'PACU Out Date_Time', 5791209258, 5791209256, 5790707710, 35451075,0, "","", 25 November 2014 22:05 ');
INSERT INTO temp
(PRSN_ID, events, EVENT_ID, c_event_id, P_event_id, EVENT_CD, TOT_TIME, TOT_TIME_UT, IN_DTTM, OUT_DTTM)
VALUES
(88346837, "PACU Total Time", 5791209260, 5791209259, 5790707710, 35451018,170, 'min', '',' ');
Desired output:
prsn_id | tot_time | tot_time_ut | in_dttm | out_dttm |
88346837 | 170 | min | 25/11/2014 19:15 | 25/11/2014 22:05 |
something like that
with m as ( select prsn_id, event, event_cd, max(c_event_id) over (partition by prsn_id, event_cd order by prsn_id, event_cd) mc_event_id, max(p_event_id) over (partition by prsn_id, event_cd order by prsn_id, event_cd, c_event_id desc) mp_event_id from temp) select t.prsn_id, max(tot_time) tot_time, max(tot_time_ut) tot_time_ut, max(in_dttm) in_dttm, max(out_dttm) out_dttm from temp t, m where t.prsn_id = m.prsn_id and t.event = m.event and t.event_cd = m.event_cd and t.c_event_id = m.mc_event_id and t.p_event_id = m.mp_event_id group by t.prsn_id;
Tags: Database
Similar Questions
-
Hello
in my application, I need the MAX value of 3 different columns.
example: column 1 = 10, 2 = 20 column, column 3 = 30 > output should be 30.
I need the MAX value to sort the list by it.
That's how I tried to do:
================================
Select t1.id,
(
SELECT MAX (SUB.value)
Of
(
SELECT
CASE TO_CHAR (ROWNUM)
WHEN TO_CHAR (1) THEN (SELECT FROM myTable WHERE id = t1.id height)
WHEN TO_CHAR (2) and THEN (SELECT FROM myTable WHERE id = t1.id width)
WHEN TO_CHAR (3) THEN (SELECT FROM myTable WHERE id = t1.id depth)
END AS value
THE t1 double
CONNECT BY ROWNUM < = 3
) VOID
) AS a kind
FROM MaTable t1
sort order
================================
This would work fine if I could reach t1 in the subselect statement (...) WHERE id = t1.id...).
Unfortunately I can not get to this point to t1.id.
does anyone have advice for me?
Thank you very much!use the LARGEST
select greatest (cola, colb, colc) from table
-
Get the Max values and average of the different cycles in the single channel
Hello
I'm trying to get the Max values and average of the single channel that has different cycles it contains. I tried to use commands such as Chnclasspeak3 and chnpeakfind, but they were not useful for me. What I need is the Max values and average of the different cycles numbers saved in the data channel.
Exampld if the string contains 5 numbers of repetitive cycles, then we must find the maximum values and the average of these 5 cycles in the single channel. Attached reference data. This is the .raw file and I have the plugin for it to use in diadem 11.1.
Kind regards
X. Ignatius
Hello, Ignatius,.
Sorry, it took some time to provide a replacement based on the script for the function. Please take a look at the attached script. I changed the script to use my function if the tiara-version is less than 12. My script function is not as fast and more stable than the implementation of tiara, but for now, it does the job
Andreas
-
How to connect the value of the input string to numeric values
Hello
I'm trying to figure out how to connect the value of unique user input string to numeric values. Basically I want the user to enter the name of a gas that I have a list for (I think I put the list of gases in a table >). Then I want to match numeric values 2 'a' and 'b', according to which gas, name of the user has set. These 'a' and 'b' values will be automatically matched with the name of the gas in a list that I put. For example, hydrogen gas has the value 3 for "a" and 4 for "b. when the user puts the ' hydrogen' name in a string constant, automatically 'a' and 'b' must be issued.» I have connect a and b to a formula
Thanks for any help
Hello
It is perhaps not exactly what you are looking for, but perhaps you could use the enumerated data type and the array of clusters of points (a, b).
Look at the VI I enclose.
-
the min and MAX values maintain their good values tia sal22
the min and MAX values maintain their good values tia sal22
Hi all
I have problems a little value to stay in their correct min and max values min and max.
Continue to change their values (up and down) trying to get the max value to only display the maximum value at a given time and the same for the min value. I looked at the examples max and min and it seems that it should be in a while loop
http://forums.NI.com/NI/board/message?board.ID=170&thread.ID=359822but I would add another while loop and if so put it in the loop for? or is there a better way to do it.
TIA sal22
Hi sal22,
I thought it was just one example you found somewhere, because it is called red rooster. See the attached example.
Mike
-
Hello
Can someone explain me why I see different values in the attached VI.
I have the array of strings, when I try to find the max value by using the Array function, I get a single value and the array of strings even when the conversion to digital, and then when I find the max value I get the different value? What I understand here?
Thank you
Repeat after me: take the max of a string array value is meaningless. He repeats it.
Repeat after me: the characters ASCII codes are NOT the same as the numeric values. He repeats it.
-
SQL, find the MAX value and placing it as a QVariant
I have a database that is loaded and defines the customerID as 0 which is ideal when the database is not be saved and restored, etc. The question I have is that I added the possibility to users to restore a backup in the app, and now I have to do a query to select MAX (customerID) so that there is no duplicate CustomerID when you add or save items. Here is the following code, I knew that I must settle, specifically the 0 highlighted in red. I need zero to be the new customerID max value:
int SettingsStorage::load(int& lastID, GroupDataModel *model) { // number of locations loaded. QSettings settings(m_author, m_appName); int loadedCount = 0; QVariant items; // Get the last customer id first. // ID's will be generated by incrementing this number // Note values coming from settings should be cast to the // required type. lastID = settings.value(m_lastCustomerIDKey, 0).toInt(); items = m_sda->execute("SELECT * from items ORDER BY datefield"); qDebug()<< "the ID" << items; // Load all the locations from the database. foreach( const QVariant& temp, items.value
() ) { Location *p; if (loadLocation(temp.value (), p)) { model->insert(p); loadedCount++; } } return loadedCount; } Ive tried the following, but it doesn't seem to do anything:
int SettingsStorage::load(int& lastID, GroupDataModel *model) { // number of locations loaded. QSettings settings(m_author, m_appName); int loadedCount = 0; QVariant items; // Get the last customer id first. // ID's will be generated by incrementing this number // Note values coming from settings should be cast to the // required type. QVariant endID = m_sda->execute("Select MAX(customerID) from items") lastID = settings.value(m_lastCustomerIDKey, endID).toInt(); items = m_sda->execute("SELECT * from items ORDER BY datefield"); qDebug()<< "the ID" << items; // Load all the locations from the database. foreach( const QVariant& temp, items.value
() ) { Location *p; if (loadLocation(temp.value (), p)) { model->insert(p); loadedCount++; } } return loadedCount; } Any help will be loved and marked solutions.
-Thanks in advance
I was wrong about executeAndWait(). Somehow, I decided that you use the SqlConnection object, but seems his SqlDataAccess. So disregard my previous post. Keep your execute method, but you must change your code to something like this:
QVariant endID = m_sda->execute("select max(customerID) as m from items"); QVariantList vlist = endID.value
(); QVariantMap vmap = vlist.first().toMap(); lastID = vmap["m"].toInt(&ok); So I changed your SQL query slightly and added "that m" so I will have something to refer later.
Then I cast QVariantList because it is where are the results.
Then because we know its going to be the only record, I took the 1st element in the list and converted to QVariantMap.
Last step is to get the maximum.
Should work this time
-
How to restrict a Min - Max value field
I have a form wih 8 areas where the user can enter the numbers. And a box of total auto calculates the values as the total sum.
But I want to restrict the total field as max value is 60.
When the max value is greater than 60, popup saying error
"Value must not exceed 60.
Mall clear fields (text1.value = "")
Thank you.
The custom calculation script could be something like:
Customized for total fields calculation script
(function () {}
var sum = 0;
An array of names of input fields
Call upon him = ['text1', 'text2', 'Text3', 'text4', 'Rem5', 'Text6', 'Text7', 'Texte8'];
Add up the values of the input fields
for (var i = 0; i)< afields.length;="" i="" +="1)">
sum += + getField(aFields[i]).value;
}
Set this field to the amount value, unless it is greater than 60
If (sum<= 60)="">=>
Event.Value = sum;
} else {/ / clears all the fields and the user to alert}
Event.Value = "";
resetForm (aFields);
App.Alert ("error goes here.", 3 ");
}
})();
Set the names of the fields in the table invoke him to match the names of the fields and to change the alert text.
-
Hi team,
I have the following query where I need to find the max value
[code]
with t as)
Select 'L1' R_nm, R_Data 'Data', 'Obj' R_Obj, r_prec 'Wd', '2' double val
Union of all the
Select 'L1', 'Data', 'Obj', 'No', '4' double
Union of all the
Select 'L2', 'Data', 'Obj', 'No', '4' double)
Select t.*, max (val) on rk (partition r_nm, r_data, r_obj) of t
[/ code]
My results should be
[code]
r_nm r_data r_obj r_prec rk val
L1 Data Obj 1 2 Wd
L1 data Obj 4 No.2
L2 Data Yes 1 1 Obj
[/ code]
Thank you
Hello
It seems that you are not interested in the MAX at all. Looks like you want to classify the lines, such as one that has the lowest value is assigned the number 1, the 2nd line with the lowest values gets 2,... and line with him gets N-th lowest value N. If is not serious if the MAX is 4, 2 or 420.
Here's a way to do it:
SELECT T.*
, RANK () OVER (PARTITION BY r_nm, r_obj)
ORDER BY val
) AS rk
T
ORDER BY r_nm, r_obj
val
;
Depending on how you want to deal with links, you can use ROW_NUMBER or DENSE_RANK instead of RANK.
-
Need to sum over all coulumns except for the needs of a coulumn max value
Hi gurus,
I have a requirement like:
I have 3 columns C1, c2, c3.
Day 1, Records values are 100,150,200
The day2 Records values are 100,150,300
End result... for the column C1 and C2, I should get sum of them
so the result for C1 according to the above values: 200
C2 = 300
But for column C3, I should get only the maximum value... like 300 (not money)...
Tuition assistance box by setting a flag on the date of the report max... We can do this... Are there others that it is possible. (End ETL or SPR or before)
Thank you.For C3 column rather than display all values like 200, 300, just to show the max value only until you capturing below as and when you sum of value remain 300. Give it a try. It can be by RPD or in the report.
Day 1, Records values are 100,150,300
The day2 Records values are 100,150,300so much sense check
Thank you
-
How to find the max value of scrollV in AS3?
I used the response from Ned to get my 3 fields of scrolling text set based on the value of one of them. Thanks Ned!
The other two text fields scroll to match the text box 'parent', but in the end – you get to the last scroll position - the other two do not update and 3 text fields are out of alignment. It's just at the end of the roll. The rest of the scroll values line up. I think that if I can find the scrollV max value, I can force the two others to scroll one last time when this value is reached by the text field "parent".
The textfield object has a property for this: maxScrollV.
-
public function get max value of column 3
Hello world
How can I determine the max value of 3 columns in ths same record
Thank youuser222 wrote:
Hello worldHow can I determine the max value of 3 columns in ths same record
Thank you
When everything has failed, read the Fine Manual
http://docs.Oracle.com/CD/E11882_01/server.112/e26088/functions069.htm#SQLRF00645
Handle: user222
Status level: Rookie (10)
Join date: April 18, 2009
Messages total: 301
Total Questions: 130 (89 pending)Why so many unanswered questions?
-
Rownum find less &; max values
Hi all
I have a doubt as to ROWNUM.
Can I use rownum to find the n less values & n max values?
This will give me values less 19 first?CREATE TABLE t1(id NUMBER(10)) SELECT ID FROM (SELECT id FROM t1 ORDER BY id ) WHERE rownum < 20.
THX
Rod.Yes, this query returns the ID values of T1 small 19.
Justin
-
How to find the first max value for each item
Hello
I have the me_result of the table as below,
SELECT * FROM me_result;
ID ||| ELITE ||||||||||| FREQ_ITEM | COMBINED_STR | SUP
1 ||; 1; 10; 2; 3; 4; 5; 7; 8. 1 ||||||||||||||; 1; 10; 2; 3; 4; 5; 7; 8 ||| 2
2 ||; 1; 10; 2; 3; 4; 5; 7; 8. 2 ||||||||||||||; 1; 10; 2; 3; 4; 5; 7; 8 ||| 2
3 ||; 1; 10; 2; 3; 4; 5; 7; 8. 3 ||||||||||||||; 1; 10; 2; 3; 4; 5; 7; 8 ||| 2
4 ||; 1; 10; 2; 3; 4; 5; 7; 8. 4 ||||||||||||||; 1; 10; 2; 3; 4; 5; 7; 8 ||| 2
5 ||; 1; 10; 2; 3; 4; 5; 7; 8. 5 ||||||||||||||; 1; 10; 2; 3; 4; 5; 7; 8 ||| 2
6 ||; 10; 2; 3; 4; 5; 8; 9. 1 ||||||||||||||; 10; 2; 3; 4; 5; 8; 9; 1 ||| 1
7 ||; 10; 2; 3; 4; 5; 8; 9. 2 ||||||||||||||; 10; 2; 3; 4; 5; 8; 9 ||| 2
8 ||; 10; 2; 3; 4; 5; 8; 9. 3 ||||||||||||||; 10; 2; 3; 4; 5; 8; 9 ||| 2
9 ||; 10; 2; 3; 4; 5; 8; 9. 4 ||||||||||||||; 10; 2; 3; 4; 5; 8; 9 ||| 2
10 ||; 10; 2; 3; 4; 5; 8; 9. 5 ||||||||||||||; 10; 2; 3; 4; 5; 8; 9 ||| 2
I need to find the first COMBINED_STR max for each element of the ELITE,
I mean, max value is the max REGEXP_COUNT (combined_str,' ;')))
really, I try to write down, but I had a lot of values for each ELITE and I need only the first, that
SELECT * from me_result
WHERE (ELITE, REGEXP_COUNT (combined_str,' ;')))) IN
(SELECT ELITE, MAX (REGEXP_COUNT (combined_str,' ;'))))) ME_RESULT ELITE GROUP);
I need the result to be as below.
1; 1; 10; 2; 3; 4; 5; 7; 8-1; 1; 10; 2; 3; 4; 5; 7; : p
6; 10; 2; 3; 4; 5; 8; 9 1; 10; 2; 3; 4; 5; 8; 9; 1 1
any help please,.
Published by: user11309581 on July 10, 2011 22:03Can be
with t as (select 1 ID, ';1;10;2;3;4;5;7;8' ELITE, 1 FREQ_ITEM, ';1;10;2;3;4;5;7;8' COMBINED_STR, 2 SUP from dual union all select 2 ,';1;10;2;3;4;5;7;8' ,2 ,';1;10;2;3;4;5;7;8' ,2 from dual union all select 3 ,';1;10;2;3;4;5;7;8' ,3 ,';1;10;2;3;4;5;7;8' ,2 from dual union all select 4 ,';1;10;2;3;4;5;7;8' ,4 ,';1;10;2;3;4;5;7;8' ,2 from dual union all select 5 ,';1;10;2;3;4;5;7;8' ,5 ,';1;10;2;3;4;5;7;8' ,2 from dual union all select 6 ,';10;2;3;4;5;8;9' ,1 ,';10;2;3;4;5;8;9;1' ,1 from dual union all select 7 ,';10;2;3;4;5;8;9' ,2 ,';10;2;3;4;5;8;9' ,2 from dual union all select 8 ,';10;2;3;4;5;8;9' ,3 ,';10;2;3;4;5;8;9' ,2 from dual union all select 9 ,';10;2;3;4;5;8;9' ,4 ,';10;2;3;4;5;8;9' ,2 from dual union all select 10 ,';10;2;3;4;5;8;9' ,5 ,';10;2;3;4;5;8;9' ,2 from dual ) select ID,ELITE,FREQ_ITEM,COMBINED_STR,SUP from ( SELECT ID,ELITE,FREQ_ITEM,COMBINED_STR,SUP, ROW_NUMBER() over (PARTITION BY ELITE order by id) RN FROM t WHERE (ELITE,REGEXP_COUNT(combined_str,';')) IN (SELECT ELITE,MAX(REGEXP_COUNT(combined_str,';')) FROM t GROUP BY ELITE) ) where RN=1 order by id ID ELITE FREQ_ITEM COMBINED_STR SUP ---------------------- ----------------- ---------------------- ----------------- ---------------------- 1 ;1;10;2;3;4;5;7;8 1 ;1;10;2;3;4;5;7;8 2 6 ;10;2;3;4;5;8;9 1 ;10;2;3;4;5;8;9;1 1
-
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
Maybe you are looking for
-
My original problem was: C:\WINDOWS\system32\rundll32.exe Application not found. I have win. XP. So I did some research and I was told that you can copy rundll32 from other parts of your computer. Yes, I did. So when I go into Add/Remove Programs, i
-
Update for Windows Vista (KB971644) platform
I recently installed "Update for Windows Vista (KB971644) platform" but when I try and install the latest version of windows live messenger, it is said that I still need to install the "platform for Windows Vista (KB971644) update" before I can insta
-
When I try to change the interactive report columns, then triggers the error: "unable to change column attributes. "ORA-01403: no data found. Pls tell me why?
-
With the help of the video in a fall and the Drag Interaction
Hi people,You are not sure if someone already did this, but is it possible to use short video clips in a water drop and drag interaction? If you, Captivate recognizes them as objects? Y at - it no problem scoring once hosted on an LMS System?Any comm
-
HelloI created a site using Muse (Beta) and uploaded to my host server. That's fine, but now I need to insert a favicon. I tried all the tips, etc. on how to do and wonder if anyone knows anyway to install the work on the cpanel of my server? I tried