SQL Query to find SUM elimating MAX n and MIN n values
Dear Gurus,
I am currently looking for a query which will provide the sum of a column eliminating the MAX n and MIN n values.
For Example,
If I have 7 values, and if n = 2, then the sum would be (23+26+36), if n = 1 then sum (14+23+26+36+39) and n will be always lesser than total no of values / 2.
12
14
23
26
36
39
45
Note: working in oracle 10g version
try this
with t as
(select 12 col from dual union all
select 14 col from dual union all
select 23 col from dual union all
select 26 col from dual union all
select 36 col from dual union all
select 39 col from dual union all
select 45 col from dual
select sum(col) from
select col,rn from
(select col, rownum rn from (select col from t order by col))
where rn > (select &n from dual) and rn <= (select count(*) from t) - &n
)also
with t as
(select 12 col from dual union all
select 14 col from dual union all
select 2 col from dual union all
select 26 col from dual union all
select 36 col from dual union all
select 3 col from dual union all
select 4 col from dual
select sum(col) from
select col
, row_number() over (order by col) rn
from t
where rn > (select &n from dual) and rn <= (select count(*) from t) - &nEdited by: AlexAnd on Apr 27, 2011 12:37 AM
Similar Messages
-
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 -
Sql query to find the balances for a customer account wise.
Hi,
Could someone help me with the sql query to find the balances for each customer account wise. This is need to generate the report.
presently we are using this query, but the output doesnot return the expected result.
SELECT sum(nvl(ps.acctd_amount_due_remaining,0)) "Balance"
FROM ra_cust_trx_line_gl_dist_all gld,
gl_code_combinations c,
ar_payment_schedules_all ps,
RA_CUSTOMER_TRX_ALL rat,
ra_customers rc
WHERE c.CHART_OF_ACCOUNTS_ID = 101
and gld.code_combination_id = c.code_combination_id
and rat.CUSTOMER_TRX_ID=gld.CUSTOMER_TRX_ID
and rat.CUSTOMER_TRX_ID=ps.CUSTOMER_TRX_ID
and ps.customer_id=rc.customer_id
and ps.status='OP'
and ps.gl_date <= :PDATE
and ps.org_id=:PORGID
and ps.class in ('GUAR','INV','DM','DEP')
and c.SEGMENT4=:Account_id
and ps.customer_id=:Customer_id
Thanks in advance.
Kalyan.Can someone help us with this.
-
Can anybody provide the SQL query to find the files uploaded in a particular folder?
Hi All,
Can anybody provide the SQL query to find the documents (document name) uploaded in a particular folder? While clicking on folder in
GUI I'm hitting the Timeout error. I would like to find the files uploaded into this folder from SQLPLUS.
Any help is greatly appreciated.
With best regards,
NevinNevin,
Be great if we could know the version of Portal. For Rel. 1, here's the query
select id,masterthingid from wwv_things
where siteid = &site
and cornerid = &corner
&site - Content Area id
&corner - Folder id
if you don't know the folder id, use
select id from wwv_corners where siteid = &site
and name = &folder
Hope this helps. I have run into this situation before. Usually, the culprits were
one of the following:
1. Junk Characters in description of item (caused due to Copy-Paste)
2. Special Characters in the File name
Hi All,
Can anybody provide the SQL query to find the documents (document name) uploaded in a particular folder? While clicking on folder in
GUI I'm hitting the Timeout error. I would like to find the files uploaded into this folder from SQLPLUS.
Any help is greatly appreciated.
With best regards,
Nevin -
SQL Query to find menus and submenus attached to responsibility
Hi,
I am looking for help to find out a sql query to pull out the list of all the menu's associated with each of the responsibilities assigned to users. Please let me know any SQL query to find out menus attached for responsibilities assigned to users.835129 wrote:
I was asked by my lead to list out responsibilities and attached menus and I was asked to submit the output from production. In the metalink note provided by you it was asked to create table collecting all menu id's and I cannot create any tables in production. Apart from this there were 1000's of users with different responsibilities and different menus. I cannot collect all of the users menu ids.
I just want to list out responsibilities and attached menus. Is that something you can helpout withhttps://forums.oracle.com/forums/search.jspa?threadID=&q=fnd_responsibility_vl+AND+fnd_menu&objID=c3&dateRange=all&userID=&numResults=15&rankBy=10001
https://forums.oracle.com/forums/search.jspa?threadID=&q=fnd_responsibility_tl+AND+FND_MENU_ENTRIES_TL&objID=c3&dateRange=all&userID=&numResults=15&rankBy=10001
Please search the forum for these tables/views and you should get many hits:
FND_MENU_ENTRIES_TL
FND_MENU_ENTRIES_VL
FND_RESPONSIBILITY_TL
FND_RESPONSIBILITY_VL
Thanks,
Hussein -
Sql query to find all contacts for an account
I wonder if someone wrote an sql query to find all contacts for an account number in Oracle customer master. We are on EBS 11.5.10.
I am also looking for sql query to find all ship to addresses for an account number.
Thanks.Can you also post the query for people who read this post and are also looking for an answer?
Regards,
Johan Louwers. -
SQl query to find incompatibility defined
If two programs are defined as incompatible with one another, the data these programs cannot access simultaneously must also be identified.
This can be found from concurrent program->define from front end ebs login, but is there any SQL query to find this for a particular program or request set??
Thanks in advance.Please search the forum before posting similar questions.
Concurrent-Conflict
Re: Concurrent-Conflict
Thanks,
Hussein -
SQL Query to find DN and phone Load
Hi All,
We are using Call Manager 8.6 [one PUB and 4 SUBs] and have different IP phone models .
IP phone model have different LOAD working with them like few 3905 have cmterm-3905.9-2-2-0 while some have cmterm-3905.9-2-2ES7 .
Is there any way/SQL Query to find out what all phone model with DN are running 3905.9-2-2.0 LOAD?
regds,
amanHey Aman,
Hope all is well my friend!
Just to add a note to my friend Carlo's good info here (+5!)
Try;
Device> Device Settings> Firmware Load Information>Device Not Using Default Load
This will show you any phones that deviate from the "device defaults" Fimware And if you click
on any device listed here it will show the actual Firmware that is being used on the specified device.
Cheers!
Rob -
SQL query to find sqlnet.ora parameters
Hi All,
I am working 11g RAC /solaris 9
I want have sql query to find values of sqlnet.ora parameters
May be values of SQLNET.INBOUND_CONNECT_TIMEOUT
SQLNET.SEND_TIMEOUT, SQLNET.RECV_TIMEOUT
Thanks
rajThe sqlnet.ora file is the profile configuration file. It resides on the client machines and the database server.
Profiles are stored and implemented using this file. The database server can be configured with access control parameters in the sqlnet.ora file.
These parameters specify whether clients are allowed or denied access based on the protocol.
The sqlnet.ora file enables you to do the following:
Specify the client domain to append to unqualified names
Prioritize naming methods
Enable logging and tracing features
Route connections through specific processes
Configure parameters for external naming
Configure Oracle Advanced Security
Use protocol-specific parameters to restrict access to the database
By default, the sqlnet.ora file is located in the ORACLE_HOME/network/admin directory. The sqlnet.ora file can also be stored in the directory specified by the TNS_ADMIN environment variable.
You can not query on this file sqlnet.ora as tnsnames.ora file.
Regards
Mahir M. Quluzade -
SQL Query to Find out User has what all resources provisioned !
Hi Guys ,
Does any one have a SQL query to find out what resources are provisioned to a particular user ?
Thanks
SurenHi,
Hope this will help you.
SELECT distinct usr_login as "IdM User ID",
usr_employeeID as "Employee ID",
usr.USR_FIRST_NAME as "First Name",
usr.USR_LAST_NAME as "Last Name",
usr_status
as "User Status",
USR_EMP_TYPE as "Employee Type",
obj.obj_name as "Application Resource",
ost_status as "Application Resource Status",
FROM ost,oiu,obj,usr,obi
WHERE oiu.ost_key = ost.ost_key AND obj.obj_key = obi.obj_key AND oiu.usr_key = usr.usr_key
AND ost_status in ('Provisioned','Revoked','Disabled', 'Provisioning')
AND oiu.obi_key=obi.obi_key
AND usr_EmployeeID like '11111'
This query will provide all the resources to which the user is linked with and the resource status is in 'Provisioned','Revoked','Disabled', 'Provisioning' status for a particular employeed ID, I am not completely sure whether I have given the Employee ID column from USR table as correct or not. Verify once and query the DB -
SQL query to find access database files?
Odd request, but does anyone have a SQL query to find files? Specifically, I am looking for machines that have access databases on them. .mdb & .accdb
Have you enabled inventory for them?
Garth Jones | My blogs: Enhansoft and
Old Blog site | Twitter:
@GarthMJ
i was trying to figure out where that option was but couldn't find it under hierarchy settings. perhaps it's been changed since 2012 R2? can you help point it out? -
Query to find First sunday of march and Second Sunday of November in SQL 2008
Hi,
I want query to find Second sunday of march and First Sunday of November in SQL 2008. This query can be used for Daylight savings(MST).
Thanks in Advance.
Regards,
LuckyAbduldeclare @d datetime,@d1 datetime
set @d = '20140301'
set @d1='20081101'
SELECT @d1
declare @baseMonday datetime
set @baseMonday = '17530101'
select
@baseMonday + datediff(day,@baseMonday,@d)/7*7+13 as Sunday,
@baseMonday + datediff(day,@baseMonday,@d1)/7*7+6 as Sunday1
Best Regards,Uri Dimant SQL Server MVP,
http://sqlblog.com/blogs/uri_dimant/
MS SQL optimization: MS SQL Development and Optimization
MS SQL Consulting:
Large scale of database and data cleansing
Remote DBA Services:
Improves MS SQL Database Performance
SQL Server Integration Services:
Business Intelligence -
Write the sql query to find largest value in row wise without using great
write the sql query to find largest value in row wise without using
greatest fuction?Another not so good way, considering you want greatest of 4 fields from a single record:
SQL> ed
Wrote file afiedt.buf
1 with t as (Select 100 col1,200 col2,300 col3,400 col4 from dual
2 union select 500,600,700,800 from dual
3 union select 900,1000,1100,1200 from dual
4 union select 1300,1400,1500,1600 from dual
5 union select 1700,1800,1900,2000 from dual
6 union select 2100,2200,2300,2400 from dual
7 union select 2800,2700,2600,2500 from dual
8 union select 2900,3000,3100,3200 from dual)
9 SELECT (CASE WHEN col1 > col2 THEN col1 ELSE col2 END) Max_value
10 FROM
11 (SELECT (CASE WHEN col1_col2 > col2_col3 THEN col1_col2 ELSE col2_col3 END) col1,
12 (CASE WHEN col2_col3 > col3_col4 THEN col2_col3 ELSE col3_col4 END) col2,
13 (CASE WHEN col3_col4 > col4_col1 THEN col3_col4 ELSE col4_col1 END) col3
14 FROM
15 (SELECT (CASE WHEN col1 > col2 THEN col1 ELSE col2 END) col1_col2,
16 (CASE WHEN col2 > col3 THEN col2 ELSE col3 END) col2_col3,
17 (CASE WHEN col3 > col4 THEN col3 ELSE col4 END) col3_col4,
18 (CASE WHEN col4 > col1 THEN col4 ELSE col1 END) col4_col1
19* FROM t))
SQL> /
MAX_VALUE
400
800
1200
1600
2000
2400
2800
3200
8 rows selected.
SQL> Edited by: AP on Sep 21, 2010 6:29 AM -
Query to find all the view name and their size in GB
Hi,
What is the query to find all the view name and their size in GB.I am aware of joining all_views and user_segments but this is not serving the purpose.is there any table i need to join to get the desired result
ThanksYou could of course be thinking of views as they are stored in other RDBMS' as some of them actually create the view as a table on the database with a copy of the data in it and maintain that data as the base tables are updated.
As already mentioned, Oracle just stores the SQL of the View and executes that SQL when the view is queried.
Alternatively, Oracle also has "materialized views" which are created as snapshots of the data and will have a size. This data is updated (refreshed) based on the parameters used when creating the materialized view which means that it will either be, commonly, when a commit is issued or when a refresh is explicitly requested (refresh on demand). -
Max delay and Min delay on same data path
Hello,
I am trying to set up timing constraints (both max and min delay) on a data path between two combinatorial elements.
I use set_max_delay -from [get_pins pin name] -to [get_pins pin name] 6 -datapath_only
set_min_delay -from [get_pins pin name] -to [get_pins pin name] 4
I checked the timing report and I see that the max_delay constraint is satisfied but the min_delay is not.What can be the reason behind this?
Also, when i comment out the first line (max_delay constraint), I see that min_delay constraint is satisfied.
Can't a datapath have both max and min delay constraints?
Any help will be really appreciated.
Thanks!
-KamathBe very careful about trying to set max/min delays on a portion of a path (i.e. not from a valid startpoint to a valid endpoint). Doing so is called path segmentation. When you do so, the max/min delay gets applied to the portion of the path you specified, but the rest of the path (between the startpoint and the set_max_delay -from and from the set_max_delay -to to the endpoint) are no longer constrained at all.
There are extremely few reasons to want to do this. I second the question "Why do you want to do this?"
That being said, you can set both a max and min delay on the same path (or path segment, if you insist on segmenting the path). The set_max_delay overrides the setup requirement, and the set_min_delay overrides the hold requirement. If the two values are too close together the tools will not be able to satisfy both; all timing checks are done at both process corners (max PVT and min PVT) - the ratio from max to min is generally around 3:1, so if the set_max_delay is less than 3x the set_min_delay the tools will be unable to satisfy both (due to real, physical limitations).
Avrum
Maybe you are looking for
-
Trying to save a csv file on my ipad so I can auto populate into a SmartForm. It will only allow me to access photos when I hit the import button
-
I am having difficulty getting Oracle 8i installed on Slackware 8. I have created the links for both /bin/free and /bin/awk. Does anyone have any insight into installing this version of the database server on this distribution of Linux? Thanks
-
What will heppen if redo logs at os level get deleted
Friends, need 1 answer about the query: what will heppen if redo logs at os level get deleted.
-
Syncing contacts merge/delete/duplicate
Hello, I am syncing an iPad and 2 iPhones with one user on our macbook. We have roughly 1500 contacts which constantly get edited/deleted/added. Now I was told at the apple store that when syncing the newest version of the contact will be the one tha
-
Can't connect to server message
I upgraded my MacBook (early 2008) to Lion and it works fine except for two messages that continue to pop up. One says that it can't connect to the server because URL with "file" extensions are not supported. The other is that I need to install a j