SQL query: I want to know how to filter data...
I want to filter these data
year | DATA_TYPE | product_name | amount |
2013 | 1 | Apple | 100 |
2013 | 1 | Mango | 200 |
2014 | 1 | Apple | 300 |
2014 | 1 | Mango | 150 |
2014 | 1 | banana | 250 |
2015 | 1 | Apple | 350 |
2015 | 2 | Apple | 300 |
2015 | 3 | Apple | 320 |
2015 | 2 | Mango | 400 |
2015 | 3 | Mango | 400 |
2015 | 3 | banana | 500 |
In each year and each product, I want to filter the data that has no data in data type 1
When he has not given in data of type 1, using data in data type 2.
and if he has not given data type 2, use the data in data of type 3.
This is the result I was expecting
year | DATA_TYPE | product_name | amount |
2015 | 2 | Mango | 400 |
2015 | 3 | banana | 500 |
Thanks for your help.
Or more simply...
SQL > ed
A written file afiedt.buf1 with t (year, data_type, product_name, amount) as)
2 Select 2013, 1, 'apple', 100 double Union all
3 select 2013, 1, "mango", 200 double Union all
4 Select 2014, 1, 'apple', 300 double Union all
5 Select 2014, 1, "mango", 150 double Union all
6 select 2014, 1, 'banana', 250 double Union all
7 if he would choose 2015, 1, 'apple', 350 dual Union all
8 select 2015, 2, 'apple', 300 double Union all
9 select 2015, 3, 'apple', 320 double Union all
10. Select 2015, 2, "mango", 400 double Union all
11. Select 2015, 3, "mango", 400 double Union all
12. Select 2015, 3, 'banana', 500 double
13 )
14-
15 end of test data
16-
17 select year
18, max (data_type) keep (first order by data_type dense_rank) as data_type
19, product_name
20, max (amount) to keep (first order by data_type dense_rank) as the amount
21 t
Group 22 by product_name, year
23 * have max (data_type) Dungeon (first order by data_type dense_rank)! = 1
SQL > /.
YEAR AMOUNT DATA_TYPE PRODUCTION
---------- ---------- ------ ----------
2015 mango 2 400
2015 banana 3 500
2 selected lines.
Tags: Database
Similar Questions
-
How to filter data in cursors within the procedure
Hello
Yesterday, I tried all night, but couldn't do it.
I know that is incomplete, I just want to know how to filter the data based on the setting in
Basically, here I want to get only the records that match the id_fichier
create or replace PROCEDURE clearing_details (p_file_id in varchar2)
IS
strStatusCode VARCHAR2 (6);
CURSOR PD1 IS
SELECT COUNTRY_CODE, EOD_MARK OF LINK_STATUS WHERE FILE_ID is p_file_id
Can someone help me on this please:
Thanks for reading.Does do the same if you run the query itself in SQL * Plus with the same value you pass as a parameter?
Without seeing your data and which parameter you're passing, we will fight help more as the concept itself works great as you have been demonstrated.
-
Since an incompetent technician clear my settings from mozilla, I get up to a page of useless information about the sender and want to know how to prevent it. I can't copy / paste an example, but there are things like x-vipre scanned. x-uidl, x-account key. These things print when I make a copy paper, waste of paper and ink.
The menu bar, select View-Headers-Normal
No menu bar? Press the ALT key.
-
I want to know how to use the fingerprint, that I had to my notes
I want to know how I put the finger impression that I would be in settings on my notes please
Not quite sure I understand what you are wanting to do.
There is no way to use the fingerprints Notes ID secure. There is no real way to even set a password for the default Notes app.
If you use a 3rd party notes App that claims to support this feature, then you should tell us that one.
There is no way to integrate the stands of fingerprint ID Notes like her.
This is a feature which will come with the next update iOS: iOS 9.3.
Thanks to anypats for the clarification.
-
I want to know how to remove the back cover of my HP product name: HP Pavilion Sleekbook 15 to install the new memory? All site shows HP Web is how remove caches memory. Unfortunately, with the newer models like mine, the whole back cover needs to be removed. I have tried in vain to remove it, but so far all that I managed to do is scratch my cover. If anyone can help?
Dear David
It's a very good idea, it would also be a good excuse to use my new phone for this. So I'll say thanks again for the good advice. Have a great weekend you Mr. As I said earlier, you're a star...
Yours Sincerely
Alan
-
I borrowed a camcorder tape Sony that has an IEEE 1394 (ilink Sony) and eager to download video from my iMac.
It would connect to the thunderbolt via an adapter port?
I have a cable of firewire 800 and wanting to know how to get the video from my iMac via this cable.
Appreciate any help you can give :)
You want a Thunderbolt Apple FireWire adapter. Here is a link (to the US store):
Sorry, I don't know what software you need to play your video, once you get the cable work.
-
I wanted to know how I can increase the font in the column of the mailbox to the left
I wanted to know how I can increase the font in the column of the mailbox to the left
Increase in the size of message font list option is available only if you select the classic layout.
When you disable the provision of the 'classic' use and return to the new layout, you need to move
the pointer of the mouse to the line splitter between the message and the list of messages and drag to the left
to decrease the width of the column of the message list.
Mail > Preferences > display
-
I wanted to know how to clean the fan b570
Hey guys I wanted to know how to clean my computer laptop fan b570 and how often should I clean fan.
Thank you for your help.
Hi Marc,
Welcome to the Community Forums of Lenovo!
You can see this interview guide and the video for the disassembly guide.
https://www.YouTube.com/watch?v=pqN1m5zhnww
http://download.Lenovo.com/consumer/mobiles_pub/lenovo_v570_b570_b570e_hmm_v2.0.PDF
Clean the fan of the laptop and repasting once a year would be nice, or if the computer is heating upward than normal.
There are a lot of application that monitors CPU and GPU temperature,
If you want to refresh the thermal paste / rebonding of your laptop, that's what we normally use
http://www.noctua.at/main.php?show=ProductView&products_id=13&LNG=en
Hope this helps
See you soon!
-
I want to know how to move the cards while trying to play stings on pogo
Original title:
Pogo games
Hello, it was a gift of birthday a week ago. So, I'm new on a laptop that I think I'm from fresh all over again. But here's my question: I want to know how to move the cards trying to play spades on pogo. Don't know how to slide or push enter or even pushing the button on the finger. Please help I really like playing Spades and pinochle. Thank you
You should ask in the forum games Pogo, not Microsoft.
http://Games-Forum.Pogo.com/
-
I want to know how to restore the computer to its factory settings, when I bought from a private party and have an administrators access code
Hello
What is the brand and model of the computer?
The best method is to contact the computer manufacturer for help on how to set the computer to its factory settings.
Hope this information helps.
-
Creative Zen V Plus 1 GB Media Player. I want to know how it works?
I have a creative zen v more 1 gb player as a gift from my sister 4years back without its installation cd & user manual. I want to know how it works?
Hello
- What is the version of the Windows operating system?
Microsoft provides no information of third-party products.
To know the product works, verify the information provided in the link mentioned below. I hope it can help you!
http://support.creative.com/kb/showarticle.aspx?SID=25966
To support more, please keep in touch with the manufacturer: http://us.creative.com/contactus/
Kind regards.
-
I want to know how can I get better ratings mscitp
I want to know how can I get better ratings mscitp
Visit the Microsoft Learning Community assistance. Thank you!
-
wanting to know how I can keep my Internet connected until I decided to unplug it
Hi, I'm wanting to know how I can keep my Internet connected until I had to unplug it. If I leave my computor minutes say 1/2 hour or if the internet wireless connection disconnects and I always have to appear to repair the connection and it says repair network adapter. Any suggestions please? Thank you
Hello
1. don't you make changes to the computer until the problem occurred?
2. What are the operating systems installed on your computer?
3. what type of connection you use?
I suggest you try the steps from the link below and check if it helps.
Method 1: Of connection problems in Windows wireless and wired network:
Method 2: I suggest you to check the parameters of the power management of the device on the network adapter.
To correct the settings please follow these steps.
(a) click Start, click Run, and then type devmgmt.msc.
(b) in the user account control dialog box, click continue.
(c) in Device Manager, expand network adapters.
(d) right click on the network driver and then click Properties.
(e) click the power management tab.
(f) click to uncheck the checkbox allow the computer to turn off this device to save power , and then click OK. If the option is checked, then uncheck the option and apply the settings.
Once you have performed the steps, restart the computer so that the changes take effect, and then check the result.
Hope this information is useful.
-
I want to know how can I go back to my old hotmail as a BLOCK / STOLEN I want to know how to get back to my hotmai
See this article for help:
http://blogs.msdn.com/b/securitytipstalk/archive/2010/07/07/Hotmail-hacked-take-these-steps.aspx
-
I want to know how to enable AutoFill on my computer Windows XP.
Please help me turn on AutoFill on my computer.
Original title: I want to know how to enable AutoFill on my comp. WinowsXp. My cousin has it on his computer.
AutoFill do you mean full auto?
If so, then proceed as follows.
1. open Internet Explorer.
2. go to tools > Internet Options > content tab
3. Select 'Settings' under the semi-automatic before heading
4. Select the options you want, or play with them until you find what works best for you.
Maybe you are looking for
-
iPhone 6 with iOS9.3.4. WiFi button does not illuminate. I rebooted the phone. How can I make this button of the device?
-
message about spyware are found in the computer
Hello Through my Safari I when I click on a link for my class assignment a message popped up and told me (with an automated voice message) it was spyware detected on my computer and I need to contact a 1-800 number to make my person information will
-
Help! ACL MASSIVE corruption
It seemed to me have made a colossal mistake to set up my iMac. I split the drive HARD internal into two partitions: OS X = P1 P2 10.10.5, = OS X 10.7.5. All updates applied Here is was I think I was wrong: I installed OS X Server 5 on the partition
-
Windows Server 2012 will not be installed
The boot order is successful in starting from my DVD. It starts to load files. So if fails with an error: "Windows has encountered a problem communicating with a device connected to your computer." ... This is a new server. I get the same problem whe
-
HP laptop 15 " Model: G56-129WM Product: XG598UA #ABA Series: [personal information] This computer currently has 3 gigabytes of ram. I would like to install more ram. I need to know how many ram slots available to add more ram and the type OF ram tha