Have the help of the clause
Oracle version 8i (we will migrate the db to 12 c in the next few months)
This is defination and data table:
create table sales
(
prod_id varchar2 (10),
PROD_NAME varchar2 (30),
salesman_id varchar2 (10),
salesman_name varchar2 (30),
commission_per varchar2 (10),
commission_amt varchar2 (10)
)
/
Insert in the value of sales ('prd1',' 1 ', ' 1', 'sm1' ", '10');
Insert in the value of sales ('prd1',' 1 ', ' 2', 'sm2' ", '10');
Insert in the value of sales ('prd1',' 1 ', ' 3', 'sm3' ", '10');
Insert in the value of sales ('2 ', 'prd2', '1', 'sm1', '10.00' ");
Insert in the value of sales ('2 ', 'prd2', '2', 'sm2', '10.00' ");
Insert in the value of sales ('3 ', 'prd3', '2', 'sm2', '10.00' ");
Insert in the value of sales ('3 ', 'prd3', '1', 'sm1', '15,00' ");
Insert in the value of sales ('3 ', 'prd3', '3', 'sm3', '10.00' ");
Insert in the value of sales ('4 ', 'prd4', '1', 'sm1', '10.00' ");
Insert in the value of sales ('4', 'prd4', ' 2 ', 'sm2' ", '15');
Insert in the value of sales ('5', 'prd5', ' 1 ', 'sm1' ", '15');
Insert in the value of sales ('6', 'prd6', ' 1 ', 'sm1' ", '15');
Insert in the value of sales ('6', 'prd6', ' 2 ', 'sm2' ", '15');
Insert in the value of sales ('6', 'prd6', ' 3 ',' sm3 ', 15', ");
Insert in the value of sales ('6', 'prd6', ' 4 ',' sm4 ', 15', ");
Insert in the value of sales ('7', 'prd7', ' 1 ', 'sm1' ", '15');
Insert in the value of sales ('7', 'prd7', ' 2 ', 'sm2' ", '15');
Insert in the value of sales ('7', 'prd7', ' 3 ', 'sm3' ", '15');
Insert in the value of sales ('7', 'prd7', ' 4 ', 'sm4' ", '15');
Insert in the value of sales ('7', 'prd7', ' 7 ', 'sm7' ", '15');
Insert in the value of sales ('7', 'prd7', ' 5 ', 'sm1' ", '10');
Insert in the value of sales ('7', 'prd7', ' 6 ', 'sm6' ", '15');
Dress uniform please:
Unique Commision Amount/Commission Percentage: PROD_ID PROD_NAME SALESMAN_I SALESMAN_NAME COMMISSION COMMISSION ---------- ------------------------------ ---------- ------------------------------ ---------- ---------- 1 prd1 1 sm1 10 2 prd2 1 sm1 10.00 5 prd5 1 sm1 15
Means, we must identify the product ID for the business that gives the same percentage of commission sales amount or commission. Percentage of different Commission amount and the Commission:
Different Commision Amount/Commission Percentage: PROD_ID PROD_NAME SALESMAN_I SALESMAN_NAME COMMISSION COMMISSION ---------- ------------------------------ ---------- ------------------------------ ---------- ---------- 3 prd3 2 sm2 10.00 3 prd3 1 sm1 15.00 3 prd3 3 sm3 10.00 4 prd4 1 sm1 10.00 4 prd4 2 sm2 15 6 prd6 1 sm1 15 6 prd6 2 sm2 15 6 prd6 3 sm3 15 6 prd6 4 sm4 15 7 prd7 1 sm1 15 7 prd7 2 sm2 15 7 prd7 3 sm3 15 7 prd7 4 sm4 15 7 prd7 7 sm7 15 7 prd7 5 sm1 10 7 prd7 6 sm6 15
Means, for the highest of the product ID, assigned amount/percentage of different sales commission to sellers; that is for a product id, there is same amount/percentage of commission which would come at the first exit, if these lines of product codes should be in the second output. Kindly help me, since we use very old version, so I think that we cannot use analytics or new SQL functions. So, please help me in a simple sql. Thank you.
I hope that this works in version 8i.
SQL > select prod_id
2, prod_name
3, salesman_id
4, salesman_name
5, commission_per
6, commission_amt
7 of)
8. Select s.*
9, mod (nvl (sum (commission_per) on (prod_id partition), 0), count (*) on (prod_id partition)) +.
10 mod (nvl (sum (commission_amt) on (prod_id partition), 0), count (*) on (prod_id partition)) val
11, row_number() over (partition by prod_id arrested by salesman_id) rno
12 s sale
13 )
14 where val = 0
15 and rno = 1;
PROD_ID PROD_NAME SALESMAN_I SALESMAN_NAME COMMISSION COMMISSION
---------- ------------------------------ ---------- ------------------------------ ---------- ----------
1 prd1 1 sm1 10
2 prd2 1 sm1 10.00
5 prd5 1 sm1 15
SQL > select prod_id
2, prod_name
3, salesman_id
4, salesman_name
5, commission_per
6, commission_amt
7 of)
8. Select s.*
9, mod (nvl (sum (commission_per) on (prod_id partition), 0), count (*) on (prod_id partition)) +.
10 mod (nvl (sum (commission_amt) on (prod_id partition), 0), count (*) on (prod_id partition)) val
11, row_number() over (partition by prod_id arrested by salesman_id) rno
12 s sale
13 )
14 where val! = 0 ;
PROD_ID PROD_NAME SALESMAN_I SALESMAN_NAME COMMISSION COMMISSION
---------- ------------------------------ ---------- ------------------------------ ---------- ----------
3 prd3 2 sm2 10.00
3 prd3 1 sm1 15.00
3 prd3 3 sm3 10.00
4 prd4 1 sm1 10.00
4 prd4 2 sm2 15
6 prd6 2 sm2 15
6 prd6 1 sm1 15
6 prd6 4 sm4 15
6 prd6 3 sm3 15
7 prd7 7 sm7 15
7 prd7 5 sm1 10
7 prd7 4 sm4 15
7 prd7 3 sm3 15
7 prd7 6 sm6 15
7 prd7 1 sm1 15
7 prd7 2 sm2 15
16 selected lines.
SQL >
Tags: Database
Similar Questions
-
SQL query help needed in the Clause type
Hello
I'm currently learning Clause type. How can I write in the clause type to get the result below:
I have a table like this
DEPTNO ENAME
------- ------
20 SMITH
CELINE 10
BOND 20
ALLEN 30
WARD 30
20 JONES
30 MARTIN
30 BLAKE
10 CLARK
SCOTT 20
10 KING
30 TURNER
20 ADAMS
30 JAMES
20 FORD
10 MILLER
I want the output should look like this
DEPTNO ENAME
------ -----
CELINE 10, CLARK, KING, MILLER
20 JONES, ADAMS, BOND, FORD, SCOTT, SMITH
30 MARTIN, JAMES BLAKE, WARD, TURNER, ALLEN
Hear is the script I am currently working on.
with emp_group as
(
Select 20 deptno, ename 'SMITH' Union double all the
choose 10, 'CÉLINE' from dual union all
Select 20, "BOND" of all the double union
Select 30, 'ALLEN' from dual union all
Select 30, 'WARD' of all the double union
Select 20, "JONES' from dual union all
Select 30, 'MARTIN' from dual union all
Select 30, "BLAKE" from dual union all
choose 10, 'CLARK' from dual union all
Select 20, 'SCOTT' from dual union all
choose 10, 'KING' of the dual union all
Select 30, 'TURNER' from dual union all
Select 20, 'ADAMS' from dual union all
Select 30, 'JAMES' of the dual union all
Select 20, 'FORD' Union double all the
choose 10, 'MILLER' from dual
)
Select
DEPTNO
A1
of emp_group
model
ignore the nav
partition (deptno)
dimension (ROW_NUMBER() over (PARTITION BY deptno ORDER BY ename DESC) rn)
measures (ename, LPAD(' ', 100) A1)
rules)
A1 [rn > 0] = ename [cv ()],
A1 [0] = ename [cv ()]
)
order by deptno
;
your help is very appreciated.
Thank you in advance.
Try this.
Select
*
Of
(
with emp_group as
(
Select 20 deptno, ename 'SMITH' Union double all the
choose 10, 'CÉLINE' from dual union all
Select 20, "BOND" of all the double union
Select 30, 'ALLEN' from dual union all
Select 30, 'WARD' of all the double union
Select 20, "JONES' from dual union all
Select 30, 'MARTIN' from dual union all
Select 30, "BLAKE" from dual union all
choose 10, 'CLARK' from dual union all
Select 20, 'SCOTT' from dual union all
choose 10, 'KING' of the dual union all
Select 30, 'TURNER' from dual union all
Select 20, 'ADAMS' from dual union all
Select 30, 'JAMES' of the dual union all
Select 20, 'FORD' Union double all the
choose 10, 'MILLER' from dual
)
Select
DEPTNO
names
rn
of emp_group
model
ignore the nav
partition (deptno)
dimension of)
ROW_NUMBER() over (PARTITION BY deptno ORDER BY ename) rn
)
measures (ename, cast (null as names of varchar2 (40)))
rules
(
names [any] order by desc = ename [cv ()] rn | «, » || names [cv () + 1]
)
order by deptno
)
where rn = 1
Best regards, Andrei
-
Help with the clause of "default".
Hi all
I have a scenario where there is a table with 75 columns. out of the 75 columns, 30 are varchar and 30 are digital. The remaining columns are other types of data when creating the table, that I forgot to mention the default values to varchar and numeric columns.
Now, approximately 20,000 records are inserted into the table where some records contain NULL varchar and numeric. Now, I want to replace the null with varchar values and digital default values respectively.
I can change the columns by adding the clause by default now and update the lines of NULL for the default values accordingly. But this process could be very heavy.
Is there a better way to do this. Please help me.
Thanks in advance,
RambeauI want to know that is it possible to set the default values for all columns of type varchar, both using a single SQL statement. Then you can update all the values NULL with default values.
You are looking for something like this?
SQL> create table t (empno default 1, ename default 'x') as select cast(null as integer) empno, cast(null as varchar2(10)) ename from emp where rownum <= 4 / Table created. SQL> select * from t / EMPNO ENAME ---------- ---------- 4 rows selected. SQL> update t set empno = default, ename=default / 4 rows updated. SQL> select * from t / EMPNO ENAME ---------- ---------- 1 x 1 x 1 x 1 x 4 rows selected.
-
I can't reach some websites with any browser. I get the message ERR_CONNECTION_REFUSED. If I boot in safe mode I don't have the issue. I tried the reset and repair of everything. Help, please
Try to run this program in your usual account, then copy and paste the result in a response. The program was created by Etresoft, a regular contributor. Use please copy and paste the screenshots can be difficult to read. On the screen with the Options, please open Options and tick the boxes in the bottom 2 before the race. Click on the button "Report share" in the toolbar, select "Copy to Clipboard" and then paste into a response. This will show what is running on your computer. No personal information is shown.
-
My iphone does not work on audio speaker and everything is perfectly fine, but when I'm on the phone and put my phone on speaker, no one can hear me not at all, but when I have the phone to my ear, or have headphones in people can hear me very well. I don't think it's a software problem, that my phone is updated with ios 9.3.5. Can someone help me please on this issue.
Force restart the phone now sleep and home for 10 seconds, button until the Apple logo comes back again. You won't lose data.
Have you tried plugging the headphones into an output a few times?
Does say "headphones" when you toggle the volume and no headphones attached?
More tips here:
If you hear no sound or distorted sound from your iPhone, iPad or iPod touch speaker - Apple Support
-
I bought a gift card a while and now I don't have the balance for her and when I try to buy I can not because I already bought it. Help, please. If I can't do my 15 birthday money are wasted. He said as I already had a gift card in my account, but somehow everything is over now when I was not yet buy anything!
A gift card is redeemable only once, it is useless to try to buy it back again.
To see what, if any, balance you have left on the account you share you: see your credit balance - Apple Support iTunes
To see what you bought on the account and therefore potentially used some/all of it: see your purchase history in iTunes on Mac or PC - Apple Support store
-
I just recently upgraded to OS El Capitan. Now, none of my movies to quicktime does not work. I have the old version of Quick time 7 and it does not work either. They do not convert. Help?
VLC will play them?
-
Help! iPad 2 keeps coming out of the recovery mode. I have the latest version of itunes and updated my drivers.
Please take a genius appointment at an Apple Store, or select another authorized service provider.
-
There are / were three problems:
1. why, when I open Firefox 9.01 this I get a message that I don't have the most recent when version help > on Firefox said I do?
2 also, with version 8 of xx, I was unable to open a new window with a right-click, until I upgraded to 9.01. (Old problem now, but I'm curious).
3 when I tried to uninstall the old version of the uninstall program told me that I had to close the open version, but it was closed according to my taskbar. I also have this problem with Thunderbird.1. you are using the latest version which is Firefox version 9.0.1
From your description, it seems that if you still have the old start page for Firefox http://www.google.com/firefox hosted by Google as your homepage. This old default home page is no longer used as topic: Home is in use since Firefox 4.0
Ignore the message, change the homepage of topic: Home, replace it with another page or leave blank.
http://support.Mozilla.org/en-us/KB/how+to+set+the+home+page
-
My husband and I have the same phone. We see them entering and fact phone outgoing calls and missed calls (phone # is in red) from the other phone. Thank you for your help.
This happens when you both share the same Apple ID. It is recommended - for a number of reasons - that each have their own Apple ID and then uses the sharing of the family for things you want to share. http://www.Apple.com/icloud/family-sharing/
-
I need to uninstall the iTunes 12.2.0.145 in Windows 7-32 bit, but I don't have the installation of this version files. Can someone help me, please?
The problem lies in a PC with Windows 7 32 bit
For general advice, see troubleshooting problems with iTunes for Windows updates.
The steps described in the second case are a guide to remove everything related to iTunes and then rebuild what is often a good starting point, unless the symptoms indicate a more specific approach. Review other cases and a list of documents to support further down the page, in which case one of them applies.
More information area has direct links with the current and recent if you have problems to download, need to revert to a previous version or try the version iTunes for Windows (64-bit-for old video cards) as a workaround for the problems of performance or compatibility with third-party software.
Your library must be affected by these measures, but it is also related to backup and recovery advice if necessary.
TT2
-
Hello.. I've forgotten the answers to my security questions... I do not have the chance to remember the... What can I do now? No idea how delet old questions and put the new ones? PLEASEEE help me
Hello
If you set an alternate e-mail address, you can reset your security questions. Follow the instructions here to check if this option is available:
If you forgot the answers to your questions of security of Apple ID - Apple Support
Otherwise, you will need to contact the Apple Support. The information is available here:
Contact Apple for assistance with the security of the Apple ID - Apple Support accounts
-
I downloaded 4 FF and now 5 and nor with my screen looks nothing like it says on the page of FF. For example, I don't have the orange FF tab in the upper left corner, I have no "PIN as app" option, nor do I view. Can someone help me please?
To get the orange FF tab, go to view > toolbars > menu bar. This should uncheck the menu bar giving you the orange button.
Panorama is a box made of 4 gray rectangles which should be on the far right, if not once you activate the orange FF tab, right click anywhere on a toolbar that doesn't has nothing to this topic, and you should get a menu with a list of your toolbars that you can check and uncheck the box. Come on down to personalize everything down and it will open a window with all your buttons. Find groups of panorama/tab button and drag it to the toolbar of your choice.
to pin a tab as an app, right-click on it; It is an option in the context menu.
-
I forgot my secret question, answer and the second email but I have the password of my ID Apple and my phone number. I want to receive by email for my secret to my Apple ID issue because it is a gmail account. Please help me
You have to ask Apple to reset your security questions. To do this, click here and choose a method; If this page does not list one for your country or if you are unable to call, complete and submit this form.
(139026) -
I have an ifone6 that is not recognized by iTunes. It has a newer version of iTunes, but when I check the updates, it says I have the latest version. Thinking that it is a matter of Win XP. Thanks for help.
You can run the latest version of iTunes for your version of Windows, but you are not running the latest version of iTunes is available and it's iTunes 12.3. You must run Windows 7 at least. I'm not a Windows user, but I think 7 is newer than XP.
Check this.
-
recently I formatted my windows XP PC. after update to show that it does not allow the genuine.but when I brought it was authentic. I have the product key with me.Please,help help find the solution
Please visit http://www.microsoft.com/genuine/ and click the Validate Windows button, then restart your computer.
If you were not able to validate, follow these steps:
1. Download this diagnostic tool, save it to your desktop: http://go.microsoft.com/fwlink/?linkid=56062
1B. double-click the executable file to run the tool.
2. after running the tool, click the Windows tab, and then click copy in the Clipboard.
NB: You can open a new file in Notepad, paste the contents of the Clipboard in it & keep for future reference.
3 start a new thread in the following forum and paste the results of the WGA diagnostic data in a post detailing the problem: http://social.microsoft.com/Forums/en-US/genuinewindowsxp/threads
4 Troubleshooting specialist will analyze the data and recommend an appropriate solution.
~ Robear Dyer (PA Bear) ~ MS MVP (that is to say, mail, security, Windows & Update Services) since 2002 ~ WARNING: MS MVPs represent or work for Microsoft
Maybe you are looking for
-
Updating BIOS for Satellite C55-A-1RG can not be downloaded - 404 not found
I can't download the update of bios for laptop Satellite C55-A-1RG.I go to http://www.toshiba-greece.com/innovation/jsp/supportMyProduct.do?LNG=28&service=SE and when I click on the link 02/12/14Update the BIOSToshiba OS independent 1, 10 - WIN World
-
We have a netbook and laptop (Wifi and Windows 7 running) who can see and transfer the content. The main computer that is wired is on Vista, but when I go to the network, I see that they are there, when I click on them I am obliged to give a usernam
-
Storage of media file in the memory of the phone blackBerry Smartphones
I'm puzzled. The assumption that the memory of the smartphone (I have an a BB 8310) would store media files for example tunes, or at least some of them, but every time I try and drag a file from the Media Manager in the memory of the device, accordin
-
Windows 8 - can I add multiple cities to my weather app?
In Windows 8 on the start page on the tile of the weather, I'm wanting to know how to add other cities, so that I can see what time where family and friends live in other parts of the country and all over the world.
-
The upgrade to ESXi 4.1 with Update Manager - disconnect SAN?
Just noticed a patch was released for ESXi 4.1, if I deploy this hotfix with Update Manager, do I have to disconnect the SAN in order to install the host? ESXi make his case of scanning for unformatted volumes and format when it restarts first after