How to find the majority of a data set
Dear Oracle GuruI have a data set something like for example
AMT of payment which includes data like this (45,53,46,45,52,45,63,45,44,45,41,45...)
I find the majority payment amt .in my given example, it's 45... IE Maximum occurrences.
I couldn't get it properly. I thought AVG and MEDIAN... but not really correct
Is there any other method or function that is deceiving me
Kindly help me out of this
With the best regards
RSS
with t
as
(
select 45 payment from dual union all
select 53 payment from dual union all
select 46 payment from dual union all
select 45 payment from dual union all
select 52 payment from dual union all
select 45 payment from dual union all
select 63 payment from dual union all
select 45 payment from dual union all
select 44 payment from dual union all
select 45 payment from dual union all
select 41 payment from dual union all
select 45 payment from dual
)
SELECT DISTINCT payment
FROM (
SELECT payment, DENSE_RANK() over (order by cnt desc) rnk
FROM (
SELECT payment, count(*) over(partition by payment order by 1) cnt
FROM t
)
)
WHERE rnk = 1
Tags: Database
Similar Questions
-
How to find the difference between two dates in time except Sunday
Hi all
I have a table, as shown below.
I would like to know the difference between same tr_ids create_time, which should give out in hours except Sunday.SQL> select * from test; TR_ID CREATE_TIME CODE -------------------------------------------------- --------------------------------------------------------------------------- ---------- S12341 05-JUN-12 12.20.52.403000 AM 1003 S12342 11-JUN-12 11.15.33.182000 AM 1003 S12342 07-JUN-12 12.00.36.573000 PM 1002 S12343 20-JUN-12 12.34.37.102000 AM 1003 S12343 15-JUN-12 11.34.27.141000 PM 1002 S12344 01-JUL-12 10.01.06.657000 PM 1002 S12344 06-JUL-12 12.01.04.188000 AM 1003 S12341 31-MAY-12 11.20.38.529000 PM 1002
For example:
TR_ID: S12344
1002_Create_time: July 1, 12 PM 10.01.06.657000 (i.e. Sunday)
1003_Create_time: 12.01.04.188000 AM 6 July 12
1002 create time is 22:00 Sunday.
If the query must exclude only the hours of Sunday which is 10 p.m. to Monday 00 h which is 2 Hrs.
I tried the sub query after doing a search on this forum but I am not getting the desired output.
Need help to get the desired o/pSELECT count(*) FROM (SELECT ROWNUM RNUM,tr_id,create_time CT_1002 FROM test c WHERE c.tr_id='S12344' and ROWNUM <= (select (cast(a.create_time as date)-cast((select create_time from test b where a.tr_id=b.tr_id and code=1002) as date)) from test a where a.code=1003 and a.tr_id=c.tr_id) + 1) d WHERE to_char(cast((select create_time from test e where e.tr_id=d.tr_id and code=1002) as date) + RNUM - 1, 'DY') NOT IN('SUN');
Hello
If I unederstand the problem correctly, that's what you want:
WITH got_extrema AS ( SELECT tr_id , CAST (MIN (create_time) AS DATE) AS start_date , CAST (MAX (create_time) AS DATE) AS end_date FROM test GROUP BY tr_id ) SELECT tr_id , start_date, end_date -- If wanted , 24 * ( ( ( TRUNC (end_date, 'IW') -- Count -1 day for every full week - TRUNC (start_date, 'IW') ) / -7 ) + LEAST ( end_date -- If end_date is a Sunday , TRUNC (end_date, 'IW') + 6 -- consider it 00:00:00 on Sunday ) - CASE WHEN start_date >= TRUNC (start_date, 'IW') + 6 -- If start_date is a Sunday THEN TRUNC (start_date, 'IW') + 6 -- consider it 00:00:00 Sunday ELSE start_date END ) AS total_hours FROM got_extrema ;
I guess that you don't need to worry about fractions of a second. As you did in the code you have posted, I am to convert the TIMESTAMP to date values, because of DATE arithmetic and functions are so much better than what is available for timestamps.
Basically, it's just to find the number of days between start_date and end_date and multiplying by 24, with these twists:
(a) 1 day is deducted for each week between start_date and end_date
(b) if End_date is a Sunday, none of the end_date himself hours are counted
(c) If start_date is a Sunday, then all the start_date himself hours are counted. Why these hours should be counted? Because 1 day is already being deducted for the week which includes start_date, which contains only this Sunday.TRUNC (dt, 'IW') is the beginning of the ISO week containing dt; in other words, 00:00:00 the or before the dt last Monday. This is not the NLS parameters.
Of course, I can't test without some sample data and the exact results you want from these data. You may need a little something more If start_date and end_date are both on the same Sunday.
Whenever you have a problem, please post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) of all of the tables involved.
Also post the results you want from this data, as well as an explanation of how you get these results from these data, with specific examples.
Always tell what version of Oracle you are using.
See the FAQ forum {message identifier: = 9360002} -
How to find the difference between two dates in the presentation layer
Hi gurus,
Hello to everyone. Today, I came with the new requirement.
I need to know the difference between a date and the current date in the formula column application presentation layer.by.
Thank you and best regards,
PratesHi Navin,
TIMESTAMPDIFF function first determines the timestamp component that corresponds to the specified interval setting. For example, SQL_TSI_DAY corresponds to the day component and SQL_TSI_MONTH corresponds to the component "month".
If you want to display the difference between two dates in days using SQL_TSI_DAY, unlike butterflies SQL_TSI_MONTH and so on...
hope you understand...
Award points and to close the debate, if your question is answered.
See you soon,.
Aravind -
How to find the date item was my favorites on Mozilla Firefox
on system moot bookmark how to find the date of the bookmark?
In bookmarks menu select organize bookmarks to open the bookmarks library. In the bookmarks library, click views, and then display the columns and then added. This will display a column showing when a bookmark has been added.
-
Hi Member
I have download the LabVIEW Machine https://decibel.ni.com/content/docs/DOC-19328 learning package
I want to run the K average algorithm to group the image in a group of two or three or more
the problem is how to find the result I mean the image of clustred', the image that contain 2 or three threatened value only
or how aasign a 1 value for all the intesity who
belong to the cluster a and 255 for data that belongs to group 2
for the look of the image as binary image?
a my vi below
Best regards
my post before shows how to set the threshold manually using the slider of the graph.
Here is the version k-means automated help .vi box tools
Alex
-
How to find the last date of execution of the objects in database
Hi all
We're going for an upgrade of the database 11g and for the same thing, we want to know the last date of the following-
Packages, Tables, views
Conc. programs / value Sets / look up / profile options
Is there a way we can find the same thing.
The answers would be really useful.
Kind regards
ShrutiSo can you provide clues on how to find the last opportunity registration
I don't think you can find such a script with having activated audit.
Thank you
Hussein -
How to find the last update date, time and user of the file field peoplecode
How to find the last updated date time fields of peoplecode records?
Thank you.We can check the update date-time using the following query
SELECT LASTUPDDTTM IN THE PSPCMPROG WHERE OBJECTVALUE1 LIKE "RECNAME" AND OBJECTVALUE2 AS "FIELDNAME".
-
How to find the difference in date in years, months and days
Hello
I need to find the difference between 2 dates in the following way "years months days". "
Please can help me, how can I achieve this.
for example, in the scott schema emp table, I need to find the difference in date between sysdate and hiredate for an employee in the following way.
12 years 7 months 4 days.Hello
Please, see this post to AskTom [difference between 2 dates | http://asktom.oracle.com/pls/asktom/f?p=100:11:0:P11_QUESTION_ID:96012348060]. There is good information in this forum, for example you can also see this thread [calculation of years, months & days | http://forums.oracle.com/forums/thread.jspa?messageID=3115216]
Kind regards
Published by: Walter Fernández on November 30, 2008 08:58 - adding another link
-
How to find the number of data items in a file written with the ArryToFile function?
I wrote a table of number in 2 groups of columns in a file using LabWindows/CVI ArrayToFile... Now, if I want to read the file with the FileToArray function so how do I know the number of items in the file. during the time of writing, I know how many elements array to write. But assume that I want the file to be read at a later time, then how to find the number of items in the file, so that I can read the exact number and present it. Thank you all
Hello
I start with the second question:
bytes_read = ReadLine (file_handle, line_buffer, maximum_bytes);
the second argument is the buffer to store the characters read, so it's an array of characters; It must be large enough to hold maximum_bytes the value NULL, if char [maximum_butes + 1]
So, obviously the number of lines in your text tiles can be determined in a loop:
Open the file
lines = 0;
While (ReadLine () > 0)
{
lines ++;
}
Close the file
-
Original title: Remove KB3035583
I deleted the update, but while they were inspecting it, I think it's still in my system in my history how to find the files to remove it completely?
I am running Windows 7
Microsoft have now updated the status of GWX, whenever changes to update is downloaded as a new update re. It is not beyond their intrigues to GWX ineffective as well. Unfortunately we have to be patient until 29 July when, according to the assurances of Microsoft this mess will be disabled. I don't know if there is code to turn it off or we wanted yet another update to do.
-
To find the first Summit for data channel
Hey guys,.
I need a little help. I wrote a script to process some data. Basically, what the script does is calculate the linear accelerations peak, peak of the angular speeds, HIC values and IF. But there is a problem with my script that I need help. In my script, I use the ChnPeakFind command to find the pics in my chains. This command works fine to find the peak value, but what I want to do is find the FIRST Summit in the data, without worrying whether or not it is a maximum. I always encountered data that varies in which my first pic (impact analysis) may or may not be the highest point in the channel. As you can see in the Graphs.png that I have attached, the ChnPeakFind command found the 2nd Summit (red circle #2) in my chain of angular velocity (ARS resulting). But what I report is the first peak value (red circle #1). I've also attached a screenshot of the section in my code where I calculate the angular velocity. The 'i' in the calculation is just the channel group number. In this case, it is 1. Anyone know how to change the code or have another suggestion how to find the first Summit in a channel without having to stop and go to the tab analysis to manually find the pic?
Thank you!
Hello
If it please see my littl below escript and let me know if this could work for you
Dim oChnResultant
Call Data.Root.Clear)
Call DataFileLoad ("E:\Customer_Examples\01_Head_Impact\Head Impact Data.tdm", "CT", "Load")
Set oChnResultant = data. Root.ActiveChannelGroup.Channels.Add ("Result", DataTypeChnFloat64)
Call ChnXYZAbsValue ("[1] / ARS X","[1] / ARS Y","[1] / ARS Z", oChnResultant)
"Use the filter twice to get rid of the jig
Call ChnSavitzkyGolayFilter (oChnResultant, oChnResultant, 1, 12)
Call ChnSavitzkyGolayFilter (oChnResultant, oChnResultant, 1, 12)
' Delete few maxima to the beginninf of the signal.
Calculate the call ("R = IIF (R)<>
'Research for first peak.
Call ChnPeakFind ("[1] / Time axis","[1]/Resultant","/PeakX","/PeakY",1,"Max.Peaks","Time")
-
How to find the velocity of an incremental encoder
I use the RE22I encoder which can give up to 8192 pulses per revolution, I have A, B, Z reports that I use an fpga as a controller Please help me.
How to find the speed of the encoder using these signals I'm going to have a clock in the fpga sysytem will help.
Start by looking at the information on Wikipedia on the rotary encoders and a book on encoders OR white. These articles will give you a basic understanding of the encoder and the signals it produces.
With proper decoding, you can get the direction and momentum of each of the points on your encoder 8192. If the tree can reverse (same vibration on one point unique all-in-mnearly stationary), full decoding must be used. If data are only of interest while the tree turns in a direction and speed will not close to zero, a simple decoding can be used. Decoding of a quadrature encoder is a good way to learn to use a state machine. Signals A and B can exist in only four possible combinations, but the possible transitions to do interesting things.
Define DECODING is a purely logical exercise and it is a simple coding in LabVIEW, such as a state machine. There are examples, Desing Patterns, or project templates (depending on your version of LV) that come with LV to help you get started.
By using the channels A and B you can update your calculation of velocity 8192 times per turn. With the help of Z you get only an update by the revolution. You use depends on your application. The pulse of Z is also useful to define a reference position for the measurement of phase angle.
Lynn
-
How to find the position of the VI icon currently run on the block diagram of the appellant
Dear forum,
I am currently trying to use a LabVIEV VI as a simple sequencer: several (very slow) actions must run one after the other. Each action is represented by a Sub - VI, some actions are executed several times. My task is to view the Subvi somehow executing.
My first intention (just manipulate the icon of the VI running with 'Icon.Get VI as Image data' / 'Icon.Set VI of Image data' invoke nodes) has failed, because it changes all instances of the VI icon. If you use the same VI several times, all these VI icons are changed (see here: http://forums.ni.com/t5/LabVIEW/How-to-change-animate-icon-of-currently-running-VI/m-p/3120754/highl... )
My current approach is to use an image of the block diagram (with "VI: block diagram: get resized Image ' call method) in a picture of the front panel control and working within this control. But for this I need to know the position of the icon of the VI running. I know that I can assess the limits and Position via the properties GObj, but how to find the VI running (note that a VI can be installed several times on the block diagram, so the name of the VI is not unique)? IMHO the easiest way might be if a VI might find its icon on the block of the appellant diagram itself when it is run...
It is clear that this position is not yet the position on the photo, but this conversion is a small piece of work...
Kind regards
cpschnuffel
-
OBIEE 11 g: how to find the 2nd Friday of the month
Hello
How to find the 2nd Friday of the month using the current date in obiee 11g.
Thanks in advance.
Kind regards
MIT.
Hey MIT,
You can try with something like this:
TIMESTAMPADD (SQL_TSI_DAY, TIMESTAMPADD (7 + 6-DAYOFWEEK (TIMESTAMPADD (SQL_TSI_DAY, 1-DAYOFMONTH (CURRENT_DATE), CURRENT_DATE))), (SQL_TSI_DAY, 1-DAYOFMONTH (CURRENT_DATE), CURRENT_DATE))
It can still be improved to probably avoid transformations 1-2, but at least he does.
You will need to check what return DAYOFWEEK in your environment for Friday (in mine Friday = 6) as if she does not return to Friday 6, you will need to adjust the formula.
The idea is to find what day is the first day of the month, since then visit the first Friday (or just stay there if the first day is a Friday). This is done by the DAYOFWEEK 6 (first day of the month).
And now, you just add more 7 days, so that's why there is a 7 + 6 - DAYOFWEEK (first day of the month) to make it easier to read and understand (instead of 13-...).
-
How to find the size of the virtual server?
Hello
We intend to pass our applications 4 virtual servers has 2 physical servers. In this process, we need to identify the size of the current virtual servers to use as a starting point to configure or add the size in physical server. can anyone provide information on whats stats to be noticed and how to find the size of the current virtual servers?
Thank you
Hi Sekhar, there.
in general, it is a fairly complex task if you want to size the new platform correctly, i.e. not to oversize it and have very low use below, i.e. spend too much on equipment.
In fact, it's the first thing to consider the level of use of the new platform. Most likely your organization (HW and infrastructure) has targets to a minimum. optimal and maximum usage levels.
In the case where you do not have this as a starting point, and then you continue with load average and the current peak (CPU, RAM, NW). To these basic lines, you can use the statistics of WLS Admin Console, where the use of CPU and memory statistics are presented since the server was last started. For more detailed statistics, you can use WLDF to capture measures key at regular intervals, and then base your analysis of these data.
Finally and above all, the size of FS, but I've seen some comments above related to the size of the FS.
HTH,
A.
Maybe you are looking for
-
How can I copy and paste my mac air photos for a pen drive? As his total 1.3 GB, its impossible to send these fotos by electronic to my friend... Please advise.
-
I play backgammon on Yahoo! Games. However, in the last few attempts to play, I go to backgammom, but when I try to read the tables, nothing comes, just a blank screen of white. I don't know if it's Java, cookies, etc... Any comments would be GREATLY
-
Qosmio F30: Multimedia keys does not work after upgrade Vista
I upgraded my laptop Toshiba Qosmio F30 Edition Vista Home premium that I have received from microsoft.After the upgrade, the multimedia keys works not (first row) and also some of the shortcuts that is done by combining the Ctrl + keys to function (
-
Windows Update/Microsoft Update error code? Error number: 0x8024400A
From formatting my computer and reinstall Windows XP or Windows Update or Microsoft Update works. "The website has encountered a problem and cannot display the page you are trying to view. The options provided below may help you solve the problem. "E
-
Hello Is there a way to convert an entire parameter to a string and save it in a string parameter, IPCC Express 3.5? Kind regards Christos