How to view the line of sql to the horizontal format based on a value.
I want to display data to the user in horizontal form based on a column value. Here is the table structure and insert. Also, I've included output expected.
If the pricemethod is "Guess", I want the value next to the price (price_real, price_guess), it will be based on the code, sellernumber and selldate.
create table TEMP_HORI ( CODE VARCHAR2(30), PRICE NUMBER(20,10), SELLDATE DATE, SELLERNUMBER NUMBER(10), PRICEMETHOD VARCHAR2(15) ); insert into temp_hori (CODE, PRICE, SELLDATE, SELLERNUMBER, PRICEMETHOD) values ('ABCD', 100.0000000000, to_date('01-10-2014', 'dd-mm-yyyy'), 100, 'Real'); insert into temp_hori (CODE, PRICE, SELLDATE, SELLERNUMBER, PRICEMETHOD) values ('ABCD', 90.0000000000, to_date('01-10-2014', 'dd-mm-yyyy'), 100, 'Guess'); insert into temp_hori (CODE, PRICE, SELLDATE, SELLERNUMBER, PRICEMETHOD) values ('ABCD', 101.0000000000, to_date('01-10-2014', 'dd-mm-yyyy'), 299, 'Real'); insert into temp_hori (CODE, PRICE, SELLDATE, SELLERNUMBER, PRICEMETHOD) values ('ABCD', 109.0000000000, to_date('01-10-2014', 'dd-mm-yyyy'), 500, 'Real');
Real:
CODE | PRICE | SELLDATE | SELLERNUMBER | PRICEMETHOD |
ABCD | 100.0000000000 | 01/10/2014 | 100 | Real |
ABCD | 90.0000000000 | 01/10/2014 | 100 | Guess |
ABCD | 101.0000000000 | 01/10/2014 | 299 | Real |
ABCD | 109.0000000000 | 01/10/2014 | 500 | Real |
Expected:
CODE | PRICE_REAL | PRICE_GUESS | SELLDATE | SELLERNUMBER |
ABCD | 100.0000000000 | 90.0000000000 | 01/10/2014 | 100 |
ABCD | 101.0000000000 | 01/10/2014 | 299 | |
ABCD | 109.0000000000 | 01/10/2014 | 500 |
Hello
This is called swivel and here's a way to do it:
SELECT code
, SUM (CASE pricemethod WHEN 'Real' price THEN END) AS price_real
SUM (CASE pricemethod when 'Guess' THEN price END) AS price_guess
selldate
sellernumber
OF temp_hori
Code of GROUP BY, selldate, sellernumber
ORDER BY code, selldate, sellernumber
;
From Oracle 11, you can also use the SELECT... PIVOT function, but it does not really help to this particular problem.
I guess just the role of the code and selldate in this problem. It is difficult to say when all the rows in the data of the sample has the same value.
Want you all sellnumbers aligned in column 1, or do you want some further to the left than others that you have posted? If the latter, is this 1 column or 2 separate columns? How do you decide which column the sellnumber appears?
For more info on pivots, see the FAQ of the Forum:
Re: 4. How can I convert rows to columns?
Tags: Database
Similar Questions
-
How to view clob data using sql
Hello
In our database we have a table that is to have a column of type CLOB but now I want to display the data using sql select query but it throws error: "unsupported data Type.
Could someone let me know how to view the clob data using the select query.
Oracle DB version: 10.2.0.3
Thank youuser562223 wrote:
HelloIn our database we have a table that is to have a column of type CLOB but now I want to display the data using sql select query but it throws error: "unsupported data Type.
Could someone let me know how to view the clob data using the select query.
Oracle DB version: 10.2.0.3
Thank you
Usually a to_char (CLOBDFIELD) circled
HTH,
FJFranken
-
How to view the monthly/annual statistics in terms of time past/calories burned, broken down by each individual activity such as run elliptical/outside etc. Y at - it a third party application that can help me to collect and display these data?
Hello
It is not currently possible to review the data the application integrated in activity or training on this basis. If you want Apple to consider adding this feature, you can suggest here:
https://www.Apple.com/feedback/watch.html
However, health and fitness data from other sources, iPhone, and Apple Watch are registered and grouped within the health on iPhone app. These data can be exported, which you may find useful to track the cumulative progress and/or analyze your activity more in detail.
IPhone app activity also has a button for sharing (top right of the screen) that allows to share data - including social media, Messages, Mail, Notes, and a printer.
Include third-party applications that can be useful, for example:
Access to QS
-"Access your HealthKit data in a table so you can Explorer using numbers, Excel, R, or any other tool compatible CSV."
- https://itunes.apple.com/gb/app/qs-access/id920297614?mt=8
SpectaRun workouts
-"View from the workouts of your Apple Watch on your iPhone and to export these workouts so you can download them to your favorite online running community."
- https://itunes.apple.com/gb/app/spectarun-workouts/id991723862?mt=8
Data can also be exported directly from the application of the health (Health Data > All - Share at the top button on the right).
Check the descriptions and support resources for third party applications for supported details of import and data analysis features.
More information:
Use the activity on your Apple Watch - Apple Support
-
How to view the PSA screenshot on front panel
Anyone know how to view the screenshot of the specturm Analyzer the PSA series on the façade. I can put the JPEG file in the C drive, but I can not display on the front panel. Please see my labview code.
Thank you, very good information
-
How to view the songs that were on the "rocket" using windows Explorer?
How to view the songs that were on the "rocket" when buying using windows Explorer?
Do you need the list or do you need knowledge where they are? If you are looking for the list just look for the Board of Directors. If you are looking for them on the "rocket" you must be connected in MTP Mode.
-
How to view the application menu in the app?
Hi all
Does anyone know how to view the application menu in the app?
The ultimate effect is that when you see the user swipe down from the top of the screen, the menu of the application.Thank you very much.
Please check the recent threads or duplicate search before posting questions: http://supportforums.blackberry.com/t5/Cascades-Development/Application-Menus/td-p/1785653
-
How to view the anticipated date of 3 days bb
Greetings
How to view the early date to 3 days with bb.
I was able to view the current in bb, but can not able to display the date fututre.
Help, please
concerning
Anthony singh
Hello
Add 3 days to the current date.
days3 long = (3 * 24 * 60 * 60 * 1000); MS
TimeFormat SimpleDateFormat = new SimpleDateFormat ("YYYY/MM/DD HH: mm: EEE");
timeString = «"+ timeFormat.formatLocal (System.currentTimeMillis () + Days3);»Thank you
Stephenson
-
How to view the status of the battery power of the screen of boot menu showing the tiles?
How to view the status of the battery power of the screen of boot menu showing the tiles?
Just do the gesture of "drag the right edge" which evokes the "charms" on the right side. It also brings a great left low Panel with date/time, battery level, and State WiFi icons. No need to clutter up the screen with him all the time. ;)
-
How to view the log with the identifier of Eloqua UI/API?
I am trying to import customer contact Eloqua system using a restful api in Java.
He got 500 Internal Server Error when call POST Api/rest/1.0/data/contact.
In fiddler, we know that answer pleased as below:
Internal server error
There was an internal server error.
The error was logged with log identifier 551654381.
Please provide this identifier to log technical support.
I want to know how to view the log of 551654381 ?
Anyone who has the experience to import contacts using the Restful API or API bulk?
Screenshot of Fiddler:
Hi Tim,.
The API error log is not available through the UI Eloqua, is accessible by Eloqua support only. If you supply the ID error when you connect to a service request with the support of Eloqua, it will make it easier for them to diagnose your problem.
-
How to view the text onto an interactive button in Indesign CC?
How to view the text onto an interactive button in Indesign CC?
I'm doing my map.
I am now able to link a button in my card to a website url, but what I really want is a way to make the text appear next to a button, it shows what kind of construction is by turning over with the mouse.
One?
-
How to view the PDF in JavaFX?
How to view the PDF in JavaFX? Thanks for the suggestions.
Not with this app as written: it simply makes each page as an image. You might be able to take advantage of the API of the PDF-Converter Labs Swing that I used in this example to get more features: I have not watched which closely.
I noticed the warnings with some codes not recognized for some PDF files. Which comes from the library of PDF-Converter, rather than any code of FX.
-
How to view the error logs in awm
I just finished my cube of construction and it failed. How to view the error log itself for me to be able to know exactly what size are the original questions. When using
Select * from cube_build_log
It does not give me the real dimensions causing problems?
Please help
Thank you
There are several levels of logging, so I would need to know more before I can tell you that one to watch.
- Have you built using MN or through DBMS_CUBE. BUILD?
- What is the exact error you received?
- What do you learn the following query?
SELECT OUTPUT, BUILD_OBJECT_TYPE, BUILD_OBJECT, BUILD_ID
OF CUBE_BUILD_LOG
WHEN STATUS = 'IMPOSSIBLE '.
ORDER BY TIMES DESC
-
Hi, I would like to ask how to view the current settings of the sequence, I'm already working the same information that is displayed when you open for the first time a new sequence
for example.
General
Editing mode: QuickTime DV PAL
Time Base: 25.00fps
Video settings
Image size: 720: 576v (1.4587)
Frame rate: 25.00 FPS
Format of the pixels: PAL D1/DV widescreen 16:9 (1.4587)
Fields: Bottom field first
Audio settings
Sample rate: 48000 samples/second
Default sequence
Total of the video tracks: 3
Master the track type: stereo
Audio tracks:
Audio 1: Standard
Audio 2: Standard
Audio 3: Standard
I forgot what setting I chose for my current sequence and tried to look under project settings , as well as the sequence settings
but do not show the news that you see when you open a new sequence for the first time, especially if the edit mode is PAL or NTSC etc.
How can I find this information which my current sequence is on?
Thank you
Sequence / sequence of setting you will find all the information.
If his pal, you're on 25 or 50 fps.
the rest is ntsc.
-
How to view the report by using the style of calendar in obiee
Hello
Can someone tell me how to view the report as the calendar?
When I choose chrystelle, it displays 31 days. 7 column, from Sunday to Saturday, and each cell displays the detailed information, such as sales from today!
Thank you!Hello
Please foloww the below blog...
http://bischool.WordPress.com/2010/10/22/calendar-view-in-OBIEE-and-applications/
Thank you
Vincent -
How to view the history of the exams?
I want to know how to make someone look at his history of review?801264 wrote:
OK, this is how you show your certificate. But how to view the history of the review?
I just spent a few hours ago 1Z0-051. Now, I want to see my own historical review. How can I do this? Via certview, or should I go directly to the website of pearson?Published by: 801264 on December 23, 2010 16:34
Pearson VIEW find out of your exam at Pearson VIEW history... but he will not know about certifications.
Certiview will be your story for review and certification. Are can be a lag of a few days between information get Pearson view at Certview.
Maybe you are looking for
-
Can I install on my MacBook 10.10.5 Sierra later
What should I do?
-
How to attach a file to my question on the support of mozilla?
I need to attach a file of about 800KB .pdf to my question on mozilla support so that those who want to help can understand and know in detail which is my real problem. How can I do?
-
The new format of community is ridiculous
Once again... Apple takes something that works very well... And "improvements" such that it is now unusable. Now, I can't find ANYTHING on these community boards I continue to by selecting "iphone" community... However, he refuses to show me the Coun
-
Need wireless driver for Satellite L655-1GL
Hey gus! I have a problem with my satellite Satellite L655.My wifi does not work. I installed the lan driver but in the support section of the site there is no Wi - Fi driver. I hope someone can help me to find it. Thanks in advance and sorry if the
-
Product key does not work - had premium windows 7 but I have now after the ultimate update
Someone help me please! I'll give you as much information as possible! I'm running on 64-bit and I had to erase my entire hard drive and re install windows (which took forever). My product key is legitimate too! If after you have reinstalled windows