How can I change this request, so I can display the name and partitions in a r
How can I change this request, so I can add the ID of the table SPRIDENfrom now on gives me what I want:
1,543 A05 24 A01 24 BAC 24 BAE 24 A02 20 BAM 20
in a single line, but I would like to add the id and the name that is stored in the SPRIDEN table
SELECT sortest_pidm,
max(decode(rn,1,sortest_tesc_code)) tesc_code1,
max(decode(rn,1,score)) score1,
max(decode(rn,2,sortest_tesc_code)) tesc_code2,
max(decode(rn,2,score)) score2,
max(decode(rn,3,sortest_tesc_code)) tesc_code3,
max(decode(rn,3,score)) score3,
max(decode(rn,4,sortest_tesc_code)) tesc_code4,
max(decode(rn,4,score)) score4,
max(decode(rn,5,sortest_tesc_code)) tesc_code5,
max(decode(rn,5,score)) score5,
max(decode(rn,6,sortest_tesc_code)) tesc_code6,
max(decode(rn,6,score)) score6
FROM (select sortest_pidm,
sortest_tesc_code,
score,
row_number() over (partition by sortest_pidm order by score desc) rn
FROM (select sortest_pidm,
sortest_tesc_code,
max(sortest_test_score) score
from sortest,SPRIDEN
where
SPRIDEN_pidm =SORTEST_PIDM
AND sortest_tesc_code in ('A01','BAE','A02','BAM','A05','BAC')
and sortest_pidm is not null
GROUP BY sortest_pidm, sortest_tesc_code))
GROUP BY sortest_pidm;
Hello
That depends on whether spriden_pidm is unique, and you want to get the results.
Whenever you have a problem, post a small example of data (CREATE TABLE and INSERT, relevamnt columns only instructions) for all the tables and the results desired from these data.
If you can illustrate your problem using tables commonly available (such as in the diagrams of scott or HR) so you need not display the sample data; right after the results you want.
Whatever it is, explain how you get these results from these data.
Always tell what version of Oracle you are using.
Looks like you are doing something similar to the following.
Using the tables emp and dept of the scott schema, producing a line of production by Department showing the highest salary for each job, for a set given jobs:
DEPTNO DNAME LOC JOB_1 SAL_1 JOB_2 SAL_2 JOB_3 SAL_3
------ -------------- ------------- ------- ----- ------- ----- ------- -----
20 RESEARCH DALLAS ANALYST 3000 MANAGER 2975 CLERK 1100
10 ACCOUNTING NEW YORK MANAGER 2450 CLERK 1300
30 SALES CHICAGO MANAGER 2850 CLERK 950
On each line, jobs are listed in order by the highest salary.
This seems to be similar to what you are doing. The roles played by the sortest_pidm, sortest_tesc_code and sortest_test_score in your table sortest are played by deptno, job and sal in the emp table. The roles played by the spriden_pidm, id and the name of your table spriden are played by deptno, dname and loc in the dept table.
Looks like you already have something like the query below, which produces a correct output, except that it does not include the dname and loc of the dept table columns.
SELECT deptno
, MAX (DECODE (rn, 1, job)) AS job_1
, MAX (DECODE (rn, 1, max_sal)) AS sal_1
, MAX (DECODE (rn, 2, job)) AS job_2
, MAX (DECODE (rn, 2, max_sal)) AS sal_2
, MAX (DECODE (rn, 3, job)) AS job_3
, MAX (DECODE (rn, 3, max_sal)) AS sal_3
FROM (
SELECT deptno
, job
, max_sal
, ROW_NUMBER () OVER ( PARTITION BY deptno
ORDER BY max_sal DESC
) AS rn
FROM (
SELECT e.deptno
, e.job
, MAX (e.sal) AS max_sal
FROM scott.emp e
, scott.dept d
WHERE e.deptno = d.deptno
AND e.job IN ('ANALYST', 'CLERK', 'MANAGER')
GROUP BY e.deptno
, e.job
)
)
GROUP BY deptno
;
Dept.DeptNo is unique, it won't be a dname and a loc for each deptno, so we can modify the query by replacing "deptno" with "deptno, dname, loc" throughout the query (except in the join condition, of course):
SELECT deptno, dname, loc -- Changed
, MAX (DECODE (rn, 1, job)) AS job_1
, MAX (DECODE (rn, 1, max_sal)) AS sal_1
, MAX (DECODE (rn, 2, job)) AS job_2
, MAX (DECODE (rn, 2, max_sal)) AS sal_2
, MAX (DECODE (rn, 3, job)) AS job_3
, MAX (DECODE (rn, 3, max_sal)) AS sal_3
FROM (
SELECT deptno, dname, loc -- Changed
, job
, max_sal
, ROW_NUMBER () OVER ( PARTITION BY deptno -- , dname, loc -- Changed
ORDER BY max_sal DESC
) AS rn
FROM (
SELECT e.deptno, d.dname, d.loc -- Changed
, e.job
, MAX (e.sal) AS max_sal
FROM scott.emp e
, scott.dept d
WHERE e.deptno = d.deptno
AND e.job IN ('ANALYST', 'CLERK', 'MANAGER')
GROUP BY e.deptno, d.dname, d.loc -- Changed
, e.job
)
)
GROUP BY deptno, dname, loc -- Changed
;
In fact, you can continue to use just deptno in the analytical PARTITION BY clause. It may be slightly more efficient to just use deptno, as I did above, but it won't change the results if you use all 3, if there is only 1 danme and 1 loc by deptno.
Moreover, you don't need so many subqueries. You use the internal subquery to calculate the MAX and the outer subquery to calculate rn. Analytical functions are calculated after global fucntions so you can do both in the same auxiliary request like this:
SELECT deptno, dname, loc
, MAX (DECODE (rn, 1, job)) AS job_1
, MAX (DECODE (rn, 1, max_sal)) AS sal_1
, MAX (DECODE (rn, 2, job)) AS job_2
, MAX (DECODE (rn, 2, max_sal)) AS sal_2
, MAX (DECODE (rn, 3, job)) AS job_3
, MAX (DECODE (rn, 3, max_sal)) AS sal_3
FROM (
SELECT e.deptno, d.dname, d.loc
, e.job
, MAX (e.sal) AS max_sal
, ROW_NUMBER () OVER ( PARTITION BY e.deptno
ORDER BY MAX (sal) DESC
) AS rn
FROM scott.emp e
, scott.dept d
WHERE e.deptno = d.deptno
AND e.job IN ('ANALYST', 'CLERK', 'MANAGER')
GROUP BY e.deptno, d.dname, d.loc
, e.job
)
GROUP BY deptno, dname, loc
;
It will work in Oracle 8.1 or more. In Oracle 11, however, it is better to use the SELECT... Function PIVOT.
Tags: Database
Similar Questions
-
How can I the date and time using regular expressions
Hi all
I have depolyed filtering the log agent. While setting properties, I would like to recover the file that is generated at the present time, but along the way, I am unable to define, what regular expression that I provide retireves date and time specific file...
Leave with kindness, men know is it possible to do?
Thanks in advance.
Shiva
This seems to be the same question I can't add a timestamp in logfilter, so I'll answer in this thread. Please check the two wires as "Answered" when the issue has been resolved.
Kind regards
Brian Wheeldon
-
How can I the Outbox and Inbox is displayed on the left side of the e-mail
do not see orsent of Inbox, sending or junk box on the left side
Hello
1. What mail client do you use?
2. the options listed on the right side of the email now?
3 did you last modified the software on the computer?
Provide us more information to help.
You may consult:
Change the appearance of Windows Mail
http://Windows.Microsoft.com/en-us/Windows-Vista/change-the-way-Windows-Mail-looks
-
How to make Windows 7 screen saver 'Photos?' display the name of pictures or pass
I have updated Windows XP Pro Sp3 to Windows 7 pro 64 English on the AMD Phenom II X 4 64 with ATI Radeon HD4650.
I liked my screensaver on XP who showed me one of my photos of 5,000 in random mode with name wich included date and place.
Can't do Windows 7!
I know that the screen saver appears not to be a big problem, but for me it means a lot. I found this question on this forum but no response.
Please help me configure screen saver Photos that I wish or find and install an old XP before I reinstall XP on my computer!Hello!
I discovered how do in reading
http://social.answers.Microsoft.com/forums/en-us/w7desktop/thread/45799d0c-38f2-40FC-B42B-4b53ef7c798f/
Then I found ssmypics.scr in terms of Windows XP and copied on W7/Windows/System32 map!
It works very well! -
can display the 6s and 6 s in addition to soda or is it only the 6 s more?
iI have just won, because I can't seem to make it work
Only 6 more and more 6s
-
Using a ring in a State Machine - can display the name of the element in each case?
In the past, I always used ropes from the States of an iteration of the loop to the other. I would try to do that digitally, with a ring or similar in order to avoid problems of typos in my strings. However, when I put it to the top with a ring, each case show that the ring number, not the descriptive text. Is it possible to implement a case structure based on digital which displays descriptive text for each case? Thank you!
Ahah! Replaced the constant of the ring with a constant in the enumeration, and everything works great now. Never mind.
-
How can I get my Contacts to the list the name and email address?
I want to copy my list of Contacts, emails. But Contacts shows only the name. How to make it so that it displays the name and email, that it was, I can copy my list?
Hi Joanne Ivy Stankievich,.
Can I know which e-mail client are you using?
If you use Hotmail.
I suggest you contact windowslivehelp.
http://Windows.Microsoft.com/en-us/Windows-Vista/import-export-or-change-the-format-for-contacts
http://Windows.Microsoft.com/en-us/Windows-Vista/managing-your-contacts
-
How to display the name of device to the file send via Bluetooth
I get this Message:
Receipt of file Conformation
You want to receive a 00:13:70:69:95:84 file?
My Question is how it can display the name of the device not the address of the device?
Post edited by: hazzaa
The same situation when I want to send pictures to cell phone on my laptop. I didn't find any option how to change.
When I send photos from mobile to mobile phone laptop computer (device name) name is displayed. Try to check the properties of the external device. Maybe you will find way to change this.
-
Machine virtual IOPS / s report, how to display the name of the data store?
Hi guys
I am new to the Foglight community, this is a great tool, and I learn a lot.
Currently I am trying to create a simple table that will show me metric of my VMware environment: Virtual Machine name, Datastore IOPS and data store.
However I can't find how to include data store name in the table, because it is not a measure of the Virtual Machine. I think I need to expand the scope of my table to include VMware Datastore, but I don't know how to do this.
-Mark
Check the options available it seems that it can be done with WCF (the frame behind the Foglight dashboards). We recommend generally customers who plan to build views WCF take adequate training or our PSO people engaged in it.
In any case I can help show a quick example of how it's done.
Please try this on a local/test server.
Go to Configuration > definition >
Make sure that you are in my definition, and click the icon to add a view. then choose from the tables and trees - oriented line table
Give a name to the view, go public and make a portlet/reportlet and apply
Switch to the configuration tab and click the change for the lines and choose a query
Under query, expand the VMware and scroll down
Until you can select the query for virtual machines
And press the set button.
Your view should look like this
Now you must select the columns.
Each column has a value you can edit and there is a button + to add additional columns.
Lets start with the name of the virtual machine - click on the button to change to your default column and choose the context.
Click on the drop down menu to enter key and choose the current line (virtual vmware machine)
Click on the drop down menu to access path and scroll down until you can select the name and then click on set.
You have created a table that lists the names of all virtual machines.
You can click on save. and then click test, choose a time and click the result. A new window will open a show the list you of virtual machines.
From here you can continue to add additional columns, each time choosing the key entry in the current line and the path to the metric/string to display.For example, the name of the data store.
I change the moduleClick the configuration tab and click the icon to add a column
For the column value, that I chose defined context once again, the key input is the current row and for the path, I expand the node for the data store
And scroll until I see the Proprietename
If you save and test you will see the result
Keep adding columns and the data you want, notice that you have arrows that allow you to control the order of the columns.
Note that you can click Show advanced configuration properties
This will give you the opportunity to see the properties of the extra table, such as header - giving you the opportunity to give a more meaningful name (name of the data store, the name of the virtual machine, etc.) to the column header.
You can now go you drag and drop the table edge/report and under my eyes, you will see your new view
Drop it in the main view
I hope this has given you the starting point to build this table.
As I said, I strongly recommend going through our WCF training if you plan build more custom views or hire software Dell PSO Organisation to help build you views that correspond to your need.
Best regards
Golan
-
I have to enter several times when idle (every few minutes). How do I change THIS setting?
Glance under Control Panel - Power Options - change Plan settings - Gina Whipp 2010 Microsoft MVP (access) Please post all responses on the forum where everyone can benefit.
-
I just bought elements of Prime Minister, but chooses 32 bit when I would have had 64. How do I change this?
To the link below, click on the still need help? option in the blue box below and choose the option to chat or by phone...
Make sure that you are logged on the Adobe site, having cookies enabled, clearing your cookie cache. If it fails to connect, try to use another browser.Get help from cat with orders, refunds and exchanges (non - CC)
http://helpx.Adobe.com/x-productkb/global/service-b.html ( http://adobe.ly/1d3k3a5 ) -
HOW CAN I GO BACK AND CHANGE A PDF OR A FILE... Online
How can I go back and open the file and edit?
Hi cindys35593486,
Are you referring to a file that you converted via the Acrobat.com online service? If so, these files are stored in your online account Acrobat.com at https://cloud.acrobat.com/files. To edit a file, you will need to download first: select the file in the file list, and then click download at the top of the list. Your file will be downloaded in the downloads to your desktop folder. from there, you can open it in the appropriate application to modify.
Notice, if you want to change a PDF file, you will need to use Acrobat. If you do not have Acrobat, you can download a free 30 day trial of http://www.adobe.com/products/acrobat.html.
Best,
Sara
-
How can I use EXISTS and no SEPARATE in this query? DDL/DML (attached)
Example queries SQL start - from the beginner to the professional by Clare Churcher(sorry about the long example script)
I have 3 tables: Member, entry, tournament (scripts DDL/DML attached below).
The members and tournament tables have no common column. Member.Membertype and Tournament.tourtype are different columns despite the similarity of its content
Table 1. Member MEMBERID LASTNAME FIRSTNAME MEMBERTYPE --------- -------------------- -------------------- -------------- 118 McKenzie Melissa Junior 138 Stone Michael Senior 153 Nolan Brenda Senior 176 Branch Helen Social 178 Beck Sarah Social 228 Burton Sandra Junior 235 Cooper William Senior 239 Spence Thomas Senior 258 Olson Barbara Senior 286 Pollard Robert Junior 290 Sexton Thomas Senior 323 Wilcox Daniel Senior 331 Schmidt Thomas Senior 332 Bridges Deborah Senior 339 Young Betty Senior 414 Gilmore Jane Junior 415 Taylor William Senior 461 Reed Robert Senior 469 Willis Carolyn Junior 487 Kent Susan Social 20 rows selected.
Table 2: Entry MEMBERID TOURID YEAR ---------- ---------- ---------- 118 24 2005 228 24 2006 228 25 2006 228 36 2006 235 38 2004 235 38 2006 235 40 2005 235 40 2006 239 25 2006 239 40 2004 258 24 2005 258 38 2005 286 24 2004 286 24 2005 286 24 2006 415 24 2006 415 25 2004 415 36 2005 415 36 2006 415 38 2004 415 38 2006 415 40 2004 415 40 2005 415 40 2006 24 rows selected.
My requirement:+.Table 3: Tournament TOURID TOURNAME TOURTYPE -------- -------------------- -------------- 24 Leeston Social 25 Kaiapoi Social 36 WestCoast Open 38 Canterbury Open 40 Otago Open
I need to find the names of all those who entered the tournament Open (tournament. Tourtype = open). So I wrote the following query
It gives me a correct result.select distinct m.memberid, m.lastname, m.firstname, t.tourtype from member m inner join entry e on (m.memberid=e.memberid) inner join tournament t on (e.tourid=t.tourid) and upper(t.tourtype)='OPEN' order by m.lastname;
But it means I can write this SQL using operator EXISTS?MEMBERID LASTNAME FIRSTNAME TOURTYPE -------- ---------- ---------- ------------------ 228 Burton Sandra Open 235 Cooper William Open 258 Olson Barbara Open 239 Spence Thomas Open 415 Taylor William Open
The DDL and DML to tables and their data
CREATE TABLE Type( Type VARCHAR2(20) Primary Key, Fee number) / CREATE TABLE Member( MemberID NUMBER Primary Key, LastName VARCHAR2(20), FirstName VARCHAR2(20), MemberType VARCHAR2(20) constraint fk1_member References type(type), Phone VARCHAR2(20), Handicap NUMBER, JoinDate DATE, Coach NUMBER, Team VARCHAR2(20), Gender VARCHAR2(1)) / CREATE TABLE Tournament( TourID NUMBER Primary Key, TourName VARCHAR2(20), TourType VARCHAR2(20)) / CREATE TABLE Entry( MemberID NUMBER constraint fk1_entry References Member(memberid), TourID NUMBER constraint fk2_entry References Tournament(tourid), Year NUMBER, constraint pk_entry Primary Key (MemberID, TourID, Year)) / Insert into Type values ('Junior',150) / Insert into Type values ('Senior',300) / Insert into Type values ('Social',50) / Insert into Member values (118,'McKenzie','Melissa','Junior','963270',30,null,null,null,'F') / Insert into Member values (138,'Stone','Michael','Senior','983223',30,null,null,null,'M') / Insert into Member values (153,'Nolan','Brenda','Senior','442649',11,null,null,'TeamB','F') / Insert into Member values (176,'Branch','Helen','Social','589419',null,null,null,null,'F') / Insert into Member values (178,'Beck','Sarah','Social','226596',null,null,null,null,'F') / Insert into Member values (228,'Burton','Sandra','Junior','244493',26,null,null,null,'F') / Insert into Member values (235,'Cooper','William','Senior','722954',14,null,null,'TeamB','M') / Insert into Member values (239,'Spence','Thomas','Senior','697720',10,null,null,null,'M') / Insert into Member values (258,'Olson','Barbara','Senior','370186',16,null,null,null,'F') / Insert into Member values (286,'Pollard','Robert','Junior','617681',19,null,null,'TeamB','M') / Insert into Member values (290,'Sexton ','Thomas','Senior','268936',26,null,null,null,'M') / Insert into Member values (323,'Wilcox','Daniel','Senior','665393',3,null,null,'TeamA','M') / Insert into Member values (331,'Schmidt','Thomas','Senior','867492',25,null,null,null,'M') / Insert into Member values (332,'Bridges','Deborah','Senior','279087',12,null,null,null,'F') / Insert into Member values (339,'Young','Betty','Senior','507813',21,null,null,'TeamB','F') / Insert into Member values (414,'Gilmore','Jane','Junior','459558',5,null,null,'TeamA','F') / Insert into Member values (415,'Taylor','William','Senior','137353',7,null,null,'TeamA','M') / Insert into Member values (461,'Reed','Robert','Senior','994664',3,null,null,'TeamA','M') / Insert into Member values (469,'Willis','Carolyn','Junior','688378',29,null,null,null,'F') / Insert into Member values (487,'Kent','Susan','Social','707217',null,null,null,null,'F') / Insert into Tournament values (24,'Leeston','Social') / Insert into Tournament values (25,'Kaiapoi','Social') / Insert into Tournament values (36,'WestCoast','Open') / Insert into Tournament values (38,'Canterbury','Open') / Insert into Tournament values (40,'Otago','Open') / Insert into Entry values (118,24,2005) / Insert into Entry values (228,24,2006) / Insert into Entry values (228,25,2006) / Insert into Entry values (228,36,2006) / Insert into Entry values (235,38,2004) / Insert into Entry values (235,38,2006) / Insert into Entry values (235,40,2005) / Insert into Entry values (235,40,2006) / Insert into Entry values (239,25,2006) / Insert into Entry values (239,40,2004) / Insert into Entry values (258,24,2005) / Insert into Entry values (258,38,2005) / Insert into Entry values (286,24,2004) / Insert into Entry values (286,24,2005) / Insert into Entry values (286,24,2006) / Insert into Entry values (415,24,2006) / Insert into Entry values (415,25,2004) / Insert into Entry values (415,36,2005) / Insert into Entry values (415,36,2006) / Insert into Entry values (415,38,2004) / Insert into Entry values (415,38,2006) / Insert into Entry values (415,40,2004) / Insert into Entry values (415,40,2005) / Insert into Entry values (415,40,2006) /
Hello, because you select tournament.tourtype in the SELECTION list, the answer is not really. If you have need of t.tourtype in the SELECT list, you might have:
select m.memberid, m.lastname, m.firstname from member m where exists (select 1 from entry e inner join tournament t on (e.tourid=t.tourid) where m.memberid=e.memberid and upper(t.tourtype)='OPEN');
And you know that the t.tourtype is 'OPEN' anyway, if you do not need to SELECT. So, you may have it, and the answer is Yes:
select m.memberid, m.lastname, m.firstname, 'OPEN' tourtype from member m where exists (select 1 from entry e inner join tournament t on (e.tourid=t.tourid) where m.memberid=e.memberid and upper(t.tourtype)='OPEN');
Published by: Seanmacgc on May 7, 2009 02:09
-
How can I bypass password and the Welcome screen on windows 7?
starting with W 7, I get an error of soul and user password. When I click ok I have 2 icons with a request of the users password. If I click ok it goes to the Welcome screen. How can I clean it and go directly to windows without password and home screen?
There is no error message. As long as you have two accounts with the listed names so there is no problem.
- - - - - - - - - -
If there is nothing wrong with the system, then you can go directly to any account chosen by:
1 click on the Start button and in the search box, type netplwiz
2 right-click on the shortcut resulting & select run as administrator.
3 in netplwiz dialog box, check the option "users must enter a user name and password to use this computer". Select the user account Standard that you want to connect automatically by clicking on the account you want to highlight, and then click apply. Enter the password for this user account (when it exists) when you are prompted, or leave blank if there is no password. Then, return to the dialog netplwiz new & still having that same account selected, uncheck "users must enter a user name and password to use this computer" then click OK.
- - - - - - - -
I do not pretend to create 2 accounts and more admin accounts that you use for day-to-day operations. It is a useful protection against the corruption of the user profiles. No matter what profile can become corrupt and if that is the only admin account that you suddenly find you have serious problems. Operation with two spare admins [which serve just to allow tasks like facilities] protects these two accounts safe against the risk of corruption of the profile day and ensures that you will have access to the system if your normal accounts is screwed up.
-
Hello! I am a member of the creative cloud. I installed Photoshop 6 in my computer 2 years ago. I need now Adobe Creative Suite. How can I get? And how it would be a month?
Please see this document
Update or change your plan of creative cloud
or contact support to see what your options are:
Maybe you are looking for
-
Version changed 28 download reading how is managed?
In our environment of the room, staff prefer to have MP3s from various sources to download open directly in the window of the program from the outside (here Goldwave is the favorite program). However, with newer versions (28 and 29 more precisely) th
-
Norton Internet Security trial version stopped working and asked me to uninstall and reinstall
Norton Internet Security has stopped working and asked me to uninstall and reinstall. I uninstalled, now I can't seem to find a way to reinstall it. Either way, it was the evaluation version of the security of the software that came with it since I b
-
Windows 7 - update error 0 x 80070003
After you install critical update KB2447568, causing my administrator user id are unable to open a session.
-
Problems for Windows 10 accepting!
Im running Windows 7 and have never had any problems with my laptop that MSE find & difficulty when I run a scan. I recently agreed to join the new 10 Windows when it is released. He said there will be some updates in the coming weeks. I installed th
-
BlackBerry Smartphones alerts email &; facebooks
I have my email and facebook put in place on my phone, but how can you get the attention (with a ringtone, ringtone, etc.)? It must be so easy, I can't figured out... any help is appreciated, thanks!