Finde min oder max in Zeitabschnitt
Hallo alle zusammen,
ich war schon lange nicht mehr hier.
Ich bin gerade dabei ein VBS zu entwickeln, um dyn. Delay Zeiten einzelner Meßsignal auf ein Trigger Signal zu synchronisieren.
Mein beliebtestes Hilfmittel ist z.Z. DIAdem 2010 unter Window 7 64Bit (für die NI Statistiker )
Mein Problem ist, dass ich weder für mein Trigger Signal ein eindeutigen Threshold festmachen kann, noch für meine zu korrigierenden Signale (hört sich wild an).
Mal angenommen mein Führungskanal (Abgasmassenstrom) hat eine steigende Flanke bei Sekunde "x", dann könnte ich sagen find()... Abgasmassenstrom > y. Problem ist nur das dieser "y" Wert sich von Test zu Test verändert und somit mein Trigger immer "weicher" wird oder gar ganz versagt.
OK dachte ich, nimmst Du halt Peaks suchen. Tolle Funktion, nur ich habe keine Möglichkeit ein Zeitfenster als Parameter an diese Funktion zu übergeben. Dies würde ich aber dringend benötigen, da ich eine Testvorlaufphase habe und ich gewisse Werte einfach ignorieren muß.
Einen Marker für das Ende der Testvorlaufphase zu setzen ist zwar für künftige Test möglich, nicht aber für bereits gefahrene.
Ich müsste folgende Peakfunktion für den Führungskanal und div. Meßkanäle abbilden
ChnPeakFind("Zeitkanal","Führungskanal",1,"Max.Peaks","Amplitude",[fromChannelLine],[toChannelLine])
für weiter Meßgrößen benötige im selben Datensatz die min. Funktion
ChnPeakFind("Zeitkanal","Führungskanal",1,"Min.Peaks","Amplitude",[fromChannelLine],[toChannelLine])
Könnte so eine Funktionserweiterung in einer nächsten Version bedacht werden, oder gibt es etwas derartiges bereits implementiert ohne das ich es gefunden habe?
Viele Grüsse
Thomas Plöger
Hallo Herr Plöger,
ich denke man könnte zweierlei dinge ausprobieren:
1.) Wenn Sie die Werte der Vorlaufzeit ignorieren wollen, und dort keine Maxima/Minima gesucht werden sollen, würde ich als Hilfslösung einfach mit DataBlCopy die Werte
ab dem Zeitpunkt, den Sie haben wollen in einen neuen Kanal kopieren und anschließend mit ChnPeakFind durchsuchen.
2.) Sie können auch alle Werte der Vorlaufzeit mit DataBlInsert auf NOVALUE setzen. Dann werden diese nicht durchsucht.
mfg
Marco Brauner NIG
Similar Messages
-
Find min and max from a bunch of numbers
hi,
i have a bunch of numbers, and i need to find the min and max.
so i have a arraylist which contains objects....whats the best way to find the min number and max number of all these objects?
thanksYou're close, but you can do them all at the same time without temp variables..
double maximumX = 0;
double minimumX = 0;
double maximumY = 0;
double minimumY = 0;
for (int i = 0; i < myobjects.size(); i++) {
mything d2d = (mything) myobjects.get(i);
maximumX = Math.max(d2d.getBounds().getMaxX(), maximumX);
minimumX= Math.min(d2d.getBounds().getMinX(), minimumX);
maximumY = Math.max(d2d.getBounds().getMaxY(), maximumY);
minimumY = Math.min(d2d.getBounds().getMinY(), minimumY);
}Since you are dealing with rectangles, you could add them all to an Area and get the bounds of the Area, but that's probably slower. -
How to find min and max of a field from sorted internal table
Hi,
I have sorted Internal Table by field f1.
How do I find max and min value of f1.
For min value of f1 I am using,
READ TABLE IT1 INDEX 1.
IT1-F1 = MIN.
Is this correct? And how do I find the max value of f1 from this table.
Thanks,
CDYes, that is right, and you can get the max like this.
data: lv_lines type i.
* get min
READ TABLE IT1 INDEX 1.
MIN = IT1-F1.
* get max
lv_lines = lines( it1 ).
read table it1 index lv_lines.
MAX = IT1-F1.
Regards,
Rich Heilman -
I have the following data stored in java. The names are stored as a 1 dimensional array and the figures as a 2 dimensional array.
-----------------------------Min Max
Joe Jones 32 22 20 10 ? ?
Jim Long 10 45 10 60 ? ?
Tom Doon 5 10 50 70 ? ?
What I want to do is to find the Mininum and Maximum value of each row. It would be displayed where the question ,marks are. What should my code be???you can use the sort method to determine which is the max/min and then return them & still keep your list as is.
something like:
-----------------------------Min Max
Joe Jones 32 22 20 10 sort.getMax() sort.getMin()
Jim Long 10 45 10 60 ? ?
Tom Doon 5 10 50 70 ? ?
for the getMax() method - return the last element in the sorted array
for the getMin() method - return the first element in the sorted array -
Optimized query to find Min and max of a col in a table
I have a table doc_boe_rec with record count 12375934
the primary key columns are (boe_rec_id,psd_serial_num).
No other ndexes are present on this table.
I want an optimized query which will give both the results :
1.Min boe_rec_id (boe_rec_id from 1st record)
2.Max boe_rec_id from this table with rows limited to a value say 5000.
i.e (boe_rec_id from 5000th column value from table )
Thanks
Manoj1.Min boe_rec_id (boe_rec_id from 1st record)It is confusing for me. The min value for the first, hmmm...
2.Max boe_rec_id from this table with rows limited to a value say 5000.Not more clear...
Please details your requirements.
Nicolas. -
SELECT * FROM (
SELECT 'STOR_A' STORE_NAME ,'BX1' BOX_NO, 'X11' LOC, '01-JAN-2010' MOVE_DT FROM DUAL UNION ALL
SELECT 'STOR_A' ,'BX1' , 'X21' , '03-JAN-2010' FROM DUAL UNION ALL
SELECT 'STOR_A' ,'BX1' , 'X13' , '05-JAN-2010' FROM DUAL UNION ALL
SELECT 'STOR_A' ,'BX1' , 'X41' , '07-JAN-2010' FROM DUAL UNION ALL
SELECT 'STOR_A' ,'BX1' , 'X15' , '09-JAN-2010' FROM DUAL UNION ALL
SELECT 'STOR_A' ,'BX2' , 'X31' , '02-JAN-2010' FROM DUAL UNION ALL
SELECT 'STOR_A' ,'BX2' , 'X71' , '04-JAN-2010' FROM DUAL UNION ALL
SELECT 'STOR_A' ,'BX2' , 'X18' , '06-JAN-2010' FROM DUAL UNION ALL
SELECT 'STOR_A' ,'BX3' , 'X91' , '04-JAN-2010' FROM DUAL UNION ALL
SELECT 'STOR_A' ,'BX3' , 'X10' , '05-JAN-2010' FROM DUAL UNION ALL
SELECT 'STOR_A' ,'BX3' , 'X14' , '07-JAN-2010' FROM DUAL UNION ALL
SELECT 'STOR_A' ,'BX3' , 'X51' , '10-JAN-2010' FROM DUAL UNION ALL
SELECT 'STOR_A' ,'BX3' , 'X16' , '12-JAN-2010' FROM DUAL UNION ALL
SELECT 'STOR_B' ,'BX2' , 'X41' , '09-JAN-2010' FROM DUAL UNION ALL
SELECT 'STOR_B' ,'BX2' , 'X74' , '11-JAN-2010' FROM DUAL UNION ALL
SELECT 'STOR_B' ,'BX2' , 'X31' , '12-JAN-2010' FROM DUAL UNION ALL
SELECT 'STOR_B' ,'BX2' , 'X68' , '17-JAN-2010' FROM DUAL
[pre/]
I have the data of the Boxes which came to the store and changed the locations on a date.
how can i select in a single row the as below. Boxwise the date and location on which received in and sent out
[pre]
BOX_NO STORE_NAME IN_LOC IN_DATE OUT_LOC OUT_DATE
BX1 STOR_A X11 01-Jan-10 X15 09-Jan-10
BX2 STOR_A X31 02-Jan-10 X18 06-Jan-10
BX3 STOR_A X91 04-Jan-10 X16 12-Jan-10
BX2 STOR_B X41 09-Jan-10 X68 17-Jan-10
[pre/]
Can someone helpout from the queryusing aggregate keep first/last functions:
with my_tab as (SELECT 'STOR_A' STORE_NAME ,'BX1' BOX_NO, 'X11' LOC, to_date('01-JAN-2010', 'dd-MON-yyyy') MOVE_DT FROM DUAL UNION ALL
SELECT 'STOR_A' ,'BX1' , 'X21' , to_date('03-JAN-2010', 'dd-MON-yyyy') FROM DUAL UNION ALL
SELECT 'STOR_A' ,'BX1' , 'X13' , to_date('05-JAN-2010', 'dd-MON-yyyy') FROM DUAL UNION ALL
SELECT 'STOR_A' ,'BX1' , 'X41' , to_date('07-JAN-2010', 'dd-MON-yyyy') FROM DUAL UNION ALL
SELECT 'STOR_A' ,'BX1' , 'X15' , to_date('09-JAN-2010', 'dd-MON-yyyy') FROM DUAL UNION ALL
SELECT 'STOR_A' ,'BX2' , 'X31' , to_date('02-JAN-2010', 'dd-MON-yyyy') FROM DUAL UNION ALL
SELECT 'STOR_A' ,'BX2' , 'X71' , to_date('04-JAN-2010', 'dd-MON-yyyy') FROM DUAL UNION ALL
SELECT 'STOR_A' ,'BX2' , 'X18' , to_date('06-JAN-2010', 'dd-MON-yyyy') FROM DUAL UNION ALL
SELECT 'STOR_A' ,'BX3' , 'X91' , to_date('04-JAN-2010', 'dd-MON-yyyy') FROM DUAL UNION ALL
SELECT 'STOR_A' ,'BX3' , 'X10' , to_date('05-JAN-2010', 'dd-MON-yyyy') FROM DUAL UNION ALL
SELECT 'STOR_A' ,'BX3' , 'X14' , to_date('07-JAN-2010', 'dd-MON-yyyy') FROM DUAL UNION ALL
SELECT 'STOR_A' ,'BX3' , 'X51' , to_date('10-JAN-2010', 'dd-MON-yyyy') FROM DUAL UNION ALL
SELECT 'STOR_A' ,'BX3' , 'X16' , to_date('12-JAN-2010', 'dd-MON-yyyy') FROM DUAL UNION ALL
SELECT 'STOR_B' ,'BX2' , 'X41' , to_date('09-JAN-2010', 'dd-MON-yyyy') FROM DUAL UNION ALL
SELECT 'STOR_B' ,'BX2' , 'X74' , to_date('11-JAN-2010', 'dd-MON-yyyy') FROM DUAL UNION ALL
SELECT 'STOR_B' ,'BX2' , 'X31' , to_date('12-JAN-2010', 'dd-MON-yyyy') FROM DUAL UNION ALL
SELECT 'STOR_B' ,'BX2' , 'X68' , to_date('17-JAN-2010', 'dd-MON-yyyy') FROM DUAL)
select box_no,
store_name,
min(loc) keep (dense_rank first order by move_dt) in_loc,
min(move_dt) in_date,
max(loc) keep (dense_rank last order by move_dt) out_loc,
max(move_dt) out_date
from my_tab
group by box_no,
store_name
order by store_name, box_no;
BOX STORE_ IN_ IN_DATE OUT OUT_DATE
BX1 STOR_A X11 01/01/2010 00:00:00 X15 09/01/2010 00:00:00
BX2 STOR_A X31 02/01/2010 00:00:00 X18 06/01/2010 00:00:00
BX3 STOR_A X91 04/01/2010 00:00:00 X16 12/01/2010 00:00:00
BX2 STOR_B X41 09/01/2010 00:00:00 X68 17/01/2010 00:00:00Edited by: Boneist on 29-Jul-2010 14:32
Oh darn it! Too slow! {noformat}*pootles off for more caffeine*{noformat} -
Hi
I wish to know is there any better way to get min(zseq) from a query statement?
I have data as :
00010 10 1 10/10/2006 - need to get tihs date (min)
00010 10 2 12/10/2006
00010 10 3 15/10/2006 - need to get this date(max-1)
00010 10 4 18/10/2006 - need to get this date (max)
My query :
SELECT ZCDD FROM ZVI2D INTO S_1ST_ZCDD
WHERE ZVBELN = WA_OUTPUT_ALL-VBELN AND ZPOSNR = WA_OUTPUT_ALL-POSNR
AND ZSEQ IN ( SELECT MIN( ZSEQ ) FROM ZVI2D WHERE ZVBELN = WA_OUTPUT_ALL-VBELN AND ZPOSNR = WA_OUTPUT_ALL-POSNR ).
AND ZDATUM = WA_OUTPUT_ALL-ZDATUM ).
ENDSELECT
I will reward points if you are able to give a good uggestion. Thanks.i think you can get max and min from the select query itself just check my previous posting for the min. But i dont think you can get the second maximum value from the select query. For that you have to store the data in itab and sort that by descending read thae table itab with index 1(max) and index 2(second largest) and last for min.
suppose you have data inyour itab.
data : lin type i.
sort itab by <field name> descending.
read table itab index 1."for max value.
write : / itab-<field>.
read table itab index 2."second largest.
write : / itab-<field>.
describe table itab lines lin.
read table itab index lin.
write : / itab-<field>.
regards
shiba dutta -
Find more than one min and max in 2D array contain 0 rows
Hi
I have a 2D array and I would like to find the max and min elements between series of 0s. As you can see in the picture If I remove all 0s from the array and use the max and min function then I will have just one min and one max but I need to find min and max after every 0 rows so you can see from the picture ( just as an example) I will have 3 min and 3 max numbers. Would you please help me with this code. Do you now any algorithm that can find min and max between 0s?
I have also attached my code to remove 0s and then search for max and min numbers but as I mentioned I need min and max for every part
Many thanks
Attachments:
2.jpg 82 KB
3.jpg 27 KBThanks altenbach
I have attached the vi to this post. I would really apperciate if you help me with this example. The min values should be 100, 1500 and 4000 and the max values should be 1200,2600,5400 so as u mentioned the output should be this 2D array
100,1200
1500,2600
4000,5400
Attachments:
new.vi 6 KB -
Hi,
I am trying to find out the latest delivery date(EINDT) for each purchasing document (EBELN) through graphical way.
The view contains other fields apart from the above mentioned two fields.
When only the two fields (EBELN, EINDT) are there, then in semantics, I can select 'Max' as aggregation to get the maximum value for each document.
If I do like this, then I need to join more than 3 views and also so many joins in calculation view. Taking so much time for data preview.
Hence , please help me in getting the solution while the view contains other fields also.
Thanks in advance.
Thanks,
JyothirmayiHi Sreehari/Vinoth,
Thank you for your replies.
if only two fields are then I can get the max/min values of one field corresponding to other field.
But more than two fields are there with different values, then let me know how to find out the max/min value of a particular filed corresponding to the 2nd field with other fields also should be in the output.
I hope you understood my issue.Please revert in case of questions.
Thanks & Regards,
Jyothirmayi -
To find out the min and max memory been used by each parameter under SGA_MA
Hi,
Can any please tell me how to find out the min and max memory been used by each parameter under SGA_MAX and SGA_TARGET ? below is the db CRMS65T. If any such script is there please provide me
SQL> select name from v$database;
NAME
CRMS65T
SQL> show parameter sga
NAME TYPE VALUE
lock_sga boolean FALSE
pre_page_sga boolean FALSE
sga_max_size big integer 1000M
sga_target big integer 1000MThanks in advanceCan any please tell me how to find out the min and max memory been used by each parameter under SGA_MAX and SGA_TARGET ? below is the db CRMS65T. If any such script is there please provide meI guess your question is, each memory components of SGA? if so
SQL> select * from v$sgainfo;
NAME BYTES RES
Fixed SGA Size 2088504 No
Redo Buffers 18882560 No
Buffer Cache Size 616562688 Yes
Shared Pool Size 301989888 Yes
Large Pool Size 4194304 Yes
Java Pool Size 4194304 Yes
Streams Pool Size 0 Yes
Granule Size 4194304 No
Maximum SGA Size 947912704 No
Startup overhead in Shared Pool 125829120 No
Free SGA Memory Available 0Also check
SQL> select COMPONENT,CURRENT_SIZE,MIN_SIZE,MAX_SIZE,USER_SPECIFIED_SIZE from v$sga_dynamic_components;
shared pool 301989888 301989888 0 209715200
large pool 4194304 4194304 0 4194304
java pool 4194304 4194304 0 4194304
streams pool 0 0 0 0
DEFAULT buffer cache 616562688 616562688 0 603979776
KEEP buffer cache 0 0 0 0
RECYCLE buffer cache 0 0 0 0
DEFAULT 2K buffer cache 0 0 0 0
DEFAULT 4K buffer cache 0 0 0 0
DEFAULT 8K buffer cache 0 0 0 0
DEFAULT 16K buffer cache 0 0 0 0
DEFAULT 32K buffer cache 0 0 0 0
ASM Buffer Cache 0 0 0 603979776
13 rows selected.
SQL>Edited by: CKPT on Sep 19, 2011 8:55 AM -
Please take a look at my code:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.text.DecimalFormat;
import java.text.NumberFormat;
public class StatisticGui extends JApplet
private JButton push;
private JButton calc;
private JTextField tf;
private JTextArea ta;
int push1,push2;
int sum=0,value,sum1=0;
int min,max,range,again;
double average;
double stad,stad1,pass;
public void init()
push1=0;
push=new JButton("Enter Num");
push.addActionListener(new button1());
calc=new JButton("Calc Stats");
calc.addActionListener(new button2());
tf=new JTextField(10);
ta=new JTextArea(16,20);
Container cp=getContentPane();
cp.setBackground(Color.gray);
cp.setLayout(new FlowLayout());
cp.add(tf,BorderLayout.WEST);
cp.add(push,BorderLayout.CENTER);
cp.add(calc,BorderLayout.CENTER);
cp.add(ta,BorderLayout.CENTER);
setSize (400,300);
private class button1 implements ActionListener
public void actionPerformed(ActionEvent event)
String text=tf.getText();
value=Integer.parseInt(text);
min=max=value;
if(value>=0)
push1++;
sum+=value;
sum1+=Math.pow(value,2);
if(value>=50)
push2++;
max = Math.max(max, value);
min = Math.min(min, value);
if(value<0)
do
again=JOptionPane.showConfirmDialog(null,"Invalid Number,Please enter again!");
while(again==JOptionPane.NO_OPTION);
average=(double)sum/push1;
pass= (double)push2 / push1;
stad = sum1/push1 - Math.pow(average,2);
stad1=Math.sqrt(stad);
range=max-min;
private class button2 implements ActionListener
public void actionPerformed(ActionEvent event)
DecimalFormat fmt=new DecimalFormat("0.##");
NumberFormat percent=NumberFormat.getPercentInstance();
ta.append("\nMean:" + fmt.format(average));
ta.append("\nStandDev:" + fmt.format(stad1));
ta.append("\nRange:" +min);
ta.append("\nPercentPass:" + percent.format(pass));
not thing wrong with my code but, i can not find the value of min and max, please help!String text=tf.getText();
value=Integer.parseInt(text);
min=max=value;So your ''max' and 'min' will be set to 'value' ...
>
if(value>=0)
push1++;
sum+=value;
sum1+=Math.pow(value,2);
if(value>=50)
push2++;
max = Math.max(max, value);
min = Math.min(min, value);And now 'min' and 'max' are calcuelated from in effect
max = Math.max(value, value);
min = Math.min(value, value);
because you have previously set 'min' and 'max' to 'value'.
not thing wrong with my code but, i can not find the
value of min and max, please help!I agree, there is nothing wrong with your code (if you want 'min' and 'max' to be the last values you supplied)! -
Pivot view - how to find min & max on a level lower than selected..
Hi all,
we have a pivot view having structure.
Year
Dept |Count| Min | MAX |
ABC | 87 | | |
XYZ | 44 | | |
Can we find out the min & max in the current year selected on quarter level & not on year and no show quarter on report. I.e the min count & max value of count in the 4 quarters.
also for below structure.
Year
| Q1 | Q2 | Q3 | Q4 |
Dept |Count| Min | MAX |Count| Min | MAX |Count| Min |MAX | Count| Min | MAX|
ABC | | | | | | | | | | | | |
XYZ | | | | | | | | | | | | |
similarly find on quarter & for quarter we want the min & max on month level. i.e minimum & max in 3 months under that quarter.
If we set the aggregation level as Min in max in pivot itself it shows the min & max same as the count as it calculates on the year level.
Thanks,
DevUsing hierarchies with exception aggregation can give strange results when aggregating to the parent nodes of the hierarchy. Recommendations:
1) check whether the results are still wrong if you deactivate the hierarchy view
2) build you exception aggregations globally. That is, do not define the exception aggregation in the structure of your query. Build it as a CKF on your InfoProvider.
3) if the above steps don't work, perhaps you can use APD or get the exception aggregations calculated in the load to the InfoProvider rather than in BEx -
Finding difference between Max date and Min date from single date field
Dear Experts,
Here I am with a scenario where i didnt find any solution in SDN and in most threads it is unanswered.
I have 1 KF which is a date field. With reference to Serial no, I want to find out the Max and Min date from the same KF. I created 2 CKF where the same KF is used in both CKF to find the Min and Max dates,
Ex:
Serial No | Material | Actual Del date | Max | Min | Difference
0123 | 300012 | 01.01.2009 | 31.01.2009 | 01.01.2009 | 30
0123 | 300013 | 07.01.2009 | 31.01.2009 | 01.01.2009 | 30
0123 | 300018 | 15.01.2009 | 31.01.2009 | 01.01.2009 | 30
0123 | 300014 | 30.01.2009 | 31.01.2009 | 01.01.2009 | 30
0124 | 300019 | 02.01.2009 | 10.01.2009 | 02.01.2009 | 8
0124 | 300012 | 06.01.2009 | 10.01.2009 | 02.01.2009 | 8
0124 | 300017 | 10.01.2009 | 10.01.2009 | 02.01.2009 | 8
This is the way how I want the output where now I am able to get the values right till Max and Min and not the difference. I even created the 3rd CKF the find the difference but it is not working.
How can I find the difference between the Max and Min dates?
Regards,
ChanHi
You have FM --DAYS_BETWEEN_TWO_DATES you can use this while Customer Exit.
Try to Have 2 RKF for Min Data and Max Date and create a formula/CKF on the same ..
Hope it helps -
Find the abs(max/min) value error.
Hi, SAP experts
Now I want to find the Abs(max) and Abs(min), (you know, for the displacement, if we want to find the max and min, we have to consider it both "+" and "-"), I use the code:
local numbervar i;
local currencyVar min;
local currencyVar max;
For i := 1 to GetNumRows-1 do
If i = 1 then
min := GridValueAt(i, CurrentColumnIndex, CurrentSummaryIndex);
max := GridValueAt(i, CurrentColumnIndex, CurrentSummaryIndex);
else
If Abs(GridValueAt(i, CurrentColumnIndex, CurrentSummaryIndex)) <= Abs(min) then
min := GridValueAt(i, CurrentColumnIndex, CurrentSummaryIndex);
If Abs(GridValueAt(i, CurrentColumnIndex, CurrentSummaryIndex)) >= Abs(max) then
max := GridValueAt(i, CurrentColumnIndex, CurrentSummaryIndex);
if CurrentFieldValue In [max, min] then
crBold
else
crRegular
But it seems not correct, why?Hi Hu,
See if this works:
local numbervar i;
local currencyVar min;
local currencyVar max;
For i := 1 to GetNumRows-1 do
If i = 1 then
min := GridValueAt(i, CurrentColumnIndex, CurrentSummaryIndex);
max := GridValueAt(i, CurrentColumnIndex, CurrentSummaryIndex);
else
If Abs(GridValueAt(i, CurrentColumnIndex, CurrentSummaryIndex)) <= Abs(min) then
min := Abs(GridValueAt(i, CurrentColumnIndex, CurrentSummaryIndex));
If Abs(GridValueAt(i, CurrentColumnIndex, CurrentSummaryIndex)) >= Abs(max) then
max := Abs(GridValueAt(i, CurrentColumnIndex, CurrentSummaryIndex));
if Abs(CurrentFieldValue) In [max, min] then
crBold
else
crRegular
-Abhilash -
MIN and MAX datetimes ti find range
I am using Oracle 11g version
create table re(Name char(20),Datetime char(45),val1 number);
insert into re values('abc','10/29/2012 13:00','1.5')
insert into re values('abc','10/29/2012 13:05','1.5')
insert into re values('abc','10/29/2012 13:10','1.5')
insert into re values('abc','10/29/2012 13:15','1.5')
insert into re values('abc','10/29/2012 13:20','0.00')
insert into re values('abc','10/29/2012 13:25','0.00')
insert into re values('abc','10/29/2012 13:30','0.00')
insert into re values('abc','10/29/2012 13:35','0.00')
insert into re values('abc','10/29/2012 13:40','2.1')
insert into re values('abc','10/29/2012 13:45','2.3')
insert into re values('abc','10/29/2012 13:50','2.1')
insert into re values('abc','10/29/2012 13:55','2.1')
insert into re values('abc','10/29/2012 14:00','2.2')
O/P:
In this way data is stored in database.Needed output is, I want the datetime column data range with min and max values where val1>0 only.
Expected result while we consider the above data is::
Name mintime maxtime
abc 10/19/2012 13:00 10/19/2012 13:15
abc 10/29/2012 13:40 10/29/2012 14:00
For this I tried something like this,
select name, min(to_date(Datetime ,'mm/dd/yyyy hh24:mi')) start, max(to_date(Datetime ,'mm/dd/yyyy hh24:mi')) end from (
select name, Datetime ,to_date(Datetime ,'mm/dd/yyyy hh24:mi') - rank() over (partition by loc_name order by t1 asc) Val_col from re where val1 > 0
) group by lname, Val_col
but I am getting the output like this for above query.
name start end
abc 10/29/2012 13:00 10/29/2012 13:00
abc 10/29/2012 13:05 10/29/2012 13:05
so.on.
Edited by: 913672 on Apr 3, 2013 3:07 AM913672 wrote:
I am using Oracle 11g version
create table re(Name char(20),Datetime char(45),val1 number);
insert into re values('abc','10/29/2012 13:00','1.5')
insert into re values('abc','10/29/2012 13:05','1.5')
insert into re values('abc','10/29/2012 13:10','1.5')
insert into re values('abc','10/29/2012 13:15','1.5')
insert into re values('abc','10/29/2012 13:20','0.00')
insert into re values('abc','10/29/2012 13:25','0.00')
insert into re values('abc','10/29/2012 13:30','0.00')
insert into re values('abc','10/29/2012 13:35','0.00')
insert into re values('abc','10/29/2012 13:40','2.1')
insert into re values('abc','10/29/2012 13:45','2.3')
insert into re values('abc','10/29/2012 13:50','2.1')
insert into re values('abc','10/29/2012 13:55','2.1')
insert into re values('abc','10/29/2012 14:00','2.2')
O/P:
In this way data is stored in database.Needed output is, I want the datetime column data range with min and max values where val1>0 only.
Expected result while we consider the above data is::
Name mintime maxtime
abc 10/19/2012 13:00 10/19/2012 13:15
abc 10/29/2012 13:40 10/29/2012 14:00
For this I tried something like this,
select name, min(to_date(Datetime ,'mm/dd/yyyy hh24:mi')) start, max(to_date(Datetime ,'mm/dd/yyyy hh24:mi')) end from (
select name, Datetime ,to_date(Datetime ,'mm/dd/yyyy hh24:mi') - rank() over (partition by loc_name order by t1 asc) Val_col from re where val1 > 0
) group by lname, Val_col
but I am getting the output like this for above query.
name start end
abc 10/29/2012 13:00 10/29/2012 13:00
abc 10/29/2012 13:05 10/29/2012 13:05
so.on.Firstly and most importantly do NOT store dates as char columns: that's what the DATE type is for.
Secondly, i'm not sure how you get your output from the input, particularly as your SQL contains 'partition by loc_name' which
doesn't even exist in your example table.
Why has the same name got two rows with those min/max times. Are you partitioning by val1?
Maybe you are looking for
-
Acrobat X, Acrobat XI, Reader: no one is playing Audio Files in a PDF
Hello everybody, thank you for supporting. I tried the following with Acrobat X, XI and Reader but I didn't find any solution... You can see the problem on the pictures... One time I get the sound, but the as I reopened the file, the error was displa
-
Product type 56A/56B - How do we draw down principal amount?
Hi All I created a credit facility using product type 56A & transaction type 200. I have flow types 1204, 1205,1206 & 1207 associated to the facility. I created a total credit line of 25 million dollars in the profiles tab & created condition types
-
Function Module to read Info cube data
Hi Guys, Is there any function module which is used to read the data in the info cube and collect the data to an internal table? Thanks Kumar
-
Using mac mini in line with a PC
I was thinking of buying a mini Mac for my 83 yo mother who currently uses a PC. Knowing that she likely would not like to just get rid of her PC for an OS she's totally unfamiliar with, I thought I might get her a Mini Mac. However, space in her hom
-
Where is all my music after reinstalling from Time Machine?
I recently did a fresh install of Lion on my laptop (now I have upgraded to Mountain Lion) and I recovered all my files from my Time Machine backup. Time machine is amazing at making my computer exactly the way I left it. Only problem is, I don't see