How can I restrict the rows of a SELECT which uses analytical functions?
Hello all,
Can anyone please tell me how to restrict the following query:
SELECT empno,
ename,
deptno,
SUM(sal) over(PARTITION BY deptno) sum_per_dept
FROM emp;
I would need just the lines which have sum_per_dept>100, without using a SUBSELECT.
Is there any way which is specific for analytical functions?
Thank you in advance,
Eugen
Message was edited by:
misailescu
SQL> select empno,
2 ename,
3 deptno,sum_per_dept
4 from
5 (
6 SELECT empno,
7 ename,
8 deptno,
9 SUM(sal) over(PARTITION BY deptno) sum_per_dept
10 FROM emp
11 )
12 where sum_per_dept>1000;
EMPNO ENAME DEPTNO SUM_PER_DEPT
7839 KING 10 8750
7782 CLARK 10 8750
7934 MILLER 10 8750
7902 FORD 20 6775
7369 SMITH 20 6775
7566 JONES 20 6775
7900 JAMES 30 9400
7844 TURNER 30 9400
7654 MARTIN 30 9400
7521 WARD 30 9400
7499 ALLEN 30 9400
7698 BLAKE 30 9400
12 rows selected
SQL>
SQL> select empno,
2 ename,
3 deptno,sum_per_dept
4 from
5 (
6 SELECT empno,
7 ename,
8 deptno,
9 SUM(sal) over(PARTITION BY deptno) sum_per_dept
10 FROM emp
11 )
12 where sum_per_dept>9000;
EMPNO ENAME DEPTNO SUM_PER_DEPT
7900 JAMES 30 9400
7844 TURNER 30 9400
7654 MARTIN 30 9400
7521 WARD 30 9400
7499 ALLEN 30 9400
7698 BLAKE 30 9400
6 rows selected
SQL> Greetings...
Sim
Similar Messages
-
How can I restrict the total no. of recs. per physical page
Hi !
I have created a report and I am saving that in a text file. The
problem is that when I try to take the output on the printer
then the total no of records overflows to the next pages and the
next page heading comes much below to it's designated place.
Max.no of records property in the repaeting frame is for the
logical page.
How can I restrict the max. number of records per physical page ?
Any pointer will be welcome,
Thanks in advance,
Shobhit
nullJust for fun (and in case this wasn't done to death in the other thread), the rule posted here states:
Most years have 365 days, but a leap year has 366 days. That adds up to 52 weeks (where each week is exactly 7 days) PLUS 1 or 2 additional days. The year 2012 has exactly 366 days.Now if the year starts on a Sunday in a non-leap year, you end up with 53 Sundays. Or if either of the first two days lands on a Sunday during a leap year, then you can also get 53 Sundays.>
which allows a calculation like this:
with test_data as
( select rownum + 1999 as test_year from dual
connect by rownum <= 15 )
select test_year
, case
when first_day = 'SUN'
or ( first_day = 'SAT' and leap_year = 'Y' )
then 53
else 52
end as sundays
from ( select test_year
, to_char(to_date(d.test_year||'-01-01','YYYY-MM-DD'),'DY', 'NLS_DATE_LANGUAGE=ENGLISH') first_day
, case extract(day from last_day(to_date(d.test_year||'-02','YYYY-MM'))) when 29 then 'Y' else 'N' end as leap_year
from test_data d );
TEST_YEAR SUNDAYS
2000 53
2001 52
2002 52
2003 52
2004 52
2005 52
2006 53
2007 52
2008 52
2009 52
2010 52
2011 52
2012 53
2013 52
2014 52
15 rows selected. -
How can we restrict the other user to add their user id's to the user group created in SQ03?
Hello All,
How can we restrict the other user to add their user id's to the user group created in SQ03?
When we enter the user group name and click on "Assign users and Infosets" button in the attached pic "User Group" .
I was able to enter my user id in other user groups. How to Grey out the other rows in the attached pic "User Group 1".How strange I answered (or at least helped) this very same question earlier today. Here the link to my previous answer then:
http://scn.sap.com/thread/3536135 -
How can i restrict the Expenditure Type values at a specific OU ?
Dear Guys,
I would like to ask about the Expenditure Types,
I have implemented two projects for different Operating Units ,
when navigating to any Projects responsibilty,and navigating the Expenditure Type field
the values exist are all the values implemented across the OU not the values entered at this OU
How can i restrict the Expenditure Type values at a specific OU
Regards
Amr HussienHello
When you set up a project there is an option called Transaction Control.
This option allow you to list the allowed or restricted elements of costs for the project.
You may enter the transaction control on a project template and that will be copied to any new project.
The cost elements may be expenditure types, expenditures categories, suppliers, employees, etc.
In your case, I suggest to set up specific project templates for each operating units. On each template enter the list of allowed expenditures types for that OU.
Doing so, the system restricts users from entering any expenditure item, supplier invoice, purchase cost etc, against an expenditure type, which is not allowed.
Dina -
How can i restrict the qty/value at the time of invoice
Hi,
Can you plesae tell me at the time of MIRO how can i restrict the user not to enter the qty more than in MIGO & PO
ThanxYou cannot restrict the qty in MIRO. because it is used for partial invoice receipt.
E.g in some cases 100 nos of qty might have received in one GR. But the supplier may give 3 invoices for this. that is the reason u cant restict this
reward if useful
SK -
How can I restrict the usage of a iPhone 5c? I would only like my daughter to be able to use her phone between 7am and 10pm central. Any ideas how to do this or an app to use?
Hi! i believe there is no preinstalled app than can do that for you, however you can use a third party software, such as this: http://www.bitworks-engineering.co.uk/Apps/TimeLock_App/Welcome.html or this https://itunes.apple.com/us/app/parental-timelock-time-limit/id689577280?mt=8
-
How can i restrict the selecting file type to XML and TXT in file upload..
Hi,
I am using Struts Upload Bean. I am also using html:file tag in the JSP. Now when i click on the browse button, A file dialogue window appears. The problem id the i want to show only text and xml files in the dialog box. Now the files of type combo box in the dialogue box is showing *.*, *.html, *.pictures (jpg/gif) options. In place of this i need to show only txt and xml files. How can i restrict the file type to XML and TXT
Regards,
Sudheesh...Hi,
the demo doesn't keep track of this. If you want then this feature isn't implemented. You will also see that the document is uploaded in a directory without changing the file name (e.g. adding the SR number). This however can be done and would be the way to do it
Frank -
How Can I Restrict the times my BT Homehub 2.0 is ...
How Can I Restrict the times my BT Homehub 2.0 is used?
i want to make sure that the kids dont go back online on their wireless laptops after i have gone to bed!!!
how can i restrict the useage times (say 11am - 11pm) for the hub/individual users - WITHOUT taking the plug out when I go to bed!!!
thanks in advance
Paulbelial wrote:
@meaga-byte: the second of those two options can be achieved by using the "BT Powersave" function. This does mean that *everyone* will lose wifi accessibility, so no watching iPlayer be for _you_ drift off! PowerSave will turn all your wifi off and back on between particular times.
This seems a more user friendly option for thoes who are not ofay with IP addresses etc.
Unless Paul wants to use wifi while in bed
If I've helped, just click the Star - Every little bit helps
If you can't fix it with a hammer, you've got an electrical problem. -
How can I display the rows into columns.
How can I display the rows into columns. I mean
Create table STYLE_M
(Master varchar2(10), child varchar2(10));
Insert itno style_m
('MASTER1','CHILD1');
Insert itno style_m
('MASTER2','CHILD1');
Insert itno style_m
('MASTER2','CHILD2');
Insert itno style_m
('MASTER3','CHILD1');
Insert itno style_m
('MASTER3','CHILD2');
Insert itno style_m
('MASTER3','CHILD3');
Note : The Master may have any number of childs.
I want to display like this..
Master child1, child2, child3, .......(dynamic)
MASTER1 CHILD1
MASTER2 CHILD1 CHILD2
MASTER3 CHILD1 CHILD2 CHILD3
Sorry for disturbing you. Please hlp me out if you have any slution.
Thanks alot.
Ram DontineniHere's a straight SQL "non-dynamic" approach.
This would be used if you knew the amount of children.
SELECT
master,
MAX(DECODE(r, 1, child, NULL)) || ' ' || MAX(DECODE(r, 2, child, NULL)) || ' ' || MAX(DECODE(r, 3, child, NULL)) children
FROM
SELECT
master,
child,
ROW_NUMBER() OVER(PARTITION BY master ORDER BY child) r
FROM
style_m
GROUP BY
master
MASTER CHILDREN
MASTER1 CHILD1
MASTER2 CHILD1 CHILD2
MASTER3 CHILD1 CHILD2 CHILD3 Since you said that the number of children can vary, I incorporated the same logic into a dynamic query.
SET AUTOPRINT ON
VAR x REFCURSOR
DECLARE
v_sql VARCHAR2(1000) := 'SELECT master, ';
v_group_by VARCHAR2(200) := 'FROM (SELECT master, child, ROW_NUMBER() OVER(PARTITION BY master ORDER BY child) r FROM style_m) GROUP BY master';
v_count PLS_INTEGER;
BEGIN
SELECT
MAX(COUNT(*))
INTO v_count
FROM
style_m
GROUP BY
master;
FOR i IN 1..v_count
LOOP
v_sql := v_sql || 'MAX(DECODE(r, ' || i || ', child, NULL))' || ' || '' '' || ';
END LOOP;
v_sql := RTRIM(v_sql, ' || '' '' ||') ||' children ' || v_group_by;
OPEN :x FOR v_sql;
END;
PL/SQL procedure successfully completed.
MASTER CHILDREN
MASTER1 CHILD1
MASTER2 CHILD1 CHILD2
MASTER3 CHILD1 CHILD2 CHILD3I'll point your other thread to this one. -
How can we restrict the objects..?
Hi it was a question asked in an interview.
How can we restrict the object..?
is it with RSSM and PFCG settings..?
Correct me if I am wrong..!
Cheers,
Vasuhi Vasu,
if the question is restriction in reporting by authorization, then you are right. take a look some bw authorization docs
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/adeac294-0501-0010-5a97-9ac5d562b1be
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/1b439590-0201-0010-ea8e-cba686f21f06
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/39f29890-0201-0010-1197-f0ed3a0d279f
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/a6329790-0201-0010-b4a1-fdd384045fdb
hope this helps. -
How can we restrict the users/planners for a planning book?
Hi experts,
How can we restrict the users/planners for a planning book?
Thanks,
Naga.Hi Naga,
we describe this in our SAP Demand and Supply Network Planning rapid-deployment solution.
Access this area directly via
http://service.sap.com
/rds-dpa
In the configuration guide Demand Planning Settings, Macros and Chart
Engine (DP3) read Appendix: Setting up Roles and
Authorizations.
BR Frank -
How can we restrict the absence status (Which are not yet to be approved)in team calendar(MSS)
Hi user570596,
I think there is no method to actually restrict the date picker popup, but you can use the ApexLib Framework (http://apexlib.sourceforge.net/) to define a min/max value for your date field. This will prevent the user from submitting the page when the date value is outside the defined range.
See http://inside-apex.blogspot.com/2007/03/min-max-value-validation-in-browser.html
for details.
Patrick
Check out my APEX-blog: http://inside-apex.blogspot.com
Check out the ApexLib Framework: http://apexlib.sourceforge.net -
How can we restrict the type of components that can be dragged and dropped from the sidekick CQ
how can we restrict the type of components that can be dragged and dropped from the sidekick CQ
Generally drop the components at parasys. The components allowed on the parsys is control via the design mode of the page.So restrict components at the design of the parsys. http://dev.day.com/docs/en/cq/current/wcm/working_with_cq_wcm/using_edit_designandpreviewm odes.html#Design%20Mode
-
How can i restrict the change of serial number in delivery document ?
how can i restrict the manual change of serial number in delivery document ?
I can tell you that you are observing standard program behavior.
By using a reference document for a return delivery, you are only
receiving proposal values for a new document. The posting will not
create a permanent link between the referred document and the return
delivery document.
Hence it is allowed to change various fields. This applies not only
to serial numbers, but to storage location, quantity and other fields. -
HOW CAN U CORRECT THE DATA IN UR FILE WHICH CONTAINS 1 LAKSH RECS
Hai Frnds,
i Attend an interview they asked this questions can u know the answeres . tell me .
In File to file scenario how can we reprocess records which failed records.
HOW CAN U CORRECT THE DATA IN UR FILE WHICH CONTAINS 1 LAKSH RECS
Thanks in advance
thahirHi,
Refer these links:
this might help you
Generic Approach for Validating Incoming Flat File in SAP XI - Part 1
Generic Approach for Validating Incoming Flat File in SAP XI - Part 1
validating against schema file for the output XML file
Informing the sender about bad records
Regards,
Nithiyanandam
Maybe you are looking for
-
Material and Service in a Single Line Req
Hi We hv a requirement of material and service in a single line item, Exampls is client ordering some fabrication work to one vendor. It involves both matl and service changre. For the matl cost we need to calculate VAT and for the service charge we
-
Mapping with both source and destination as flat files???
hi I have two two flat files(large data) for example A and B. let us say A has records of format( characteres of size(5) , numbers of size(6) , characteres of size(5) ) B has records of format( characteres of size(5) , numbers of size(6) ) i have to
-
DML operations improves perfomance on a Partioned Table?
Hi We have a simple table (non-partitioned) and we do normal DML operations on it. If we convert that table into 5 partitions then does DML performance improves on it by 5times? To be very specific will READ and WRITES on table will improve? if YES t
-
Problem with one to one unidirectional relation
Hi, I have one problem with one to one relation ship. While i am trying to persist the objects it is showing that "parent key not found" exception. Is there any problem with my class configuration ?.. Table description:having two tables with same com
-
Info about Tax on sales/purchase from a business perspective
Hello everybody, Where could I find information about tax on sales/purchase? I am especially looking for info from a business perspective. The questions I try to answer are, for example, the followings: - What are the main business issues regarding V