Need help to restrict to a result set of a UNION in FUSION
Hello
Would be really grateful if someone could help me with the problem I am facing with the statements below (I'm new to Oracle ):
merge into table_name_1 p
using
(
Select p_key, value_1, value_2
of some_tables
UNION
Select p_key, value_1, value_2
of some_tables
UNION
.....;
) t
on (p.p_key = t.p_key)
When matched then
Update table_name_1 with value_1 and value_2
When not matched then
Insert table_name_1 with p_key, value_1 value_2;
Now, the union of all these selects me gives distinct values and it works most of the time, but when I have values like below, the merge fails:
p_key - value_1 - value_2
100 25-50
100 NULL - 50
I scoured the net and understand the reason behind it: the result set becomes ambiguous and fusion does not know what line to insert first and including an update.
Now my requirement is: I might sub sets of scenario/result of the union and I need only 1 row by p_key.
result_set_1
p_key - value_1 - value_2
100 - 25-50 * need this line
100 NULL - 50
100 - NULL NULL
result_set_2
p_key - value_1 - value_2
100-25 - NULL * need this line
100 - NULL NULL
result_set_3
p_key - value_1 - value_2
100-25 - NULL * need to this line (p_key = 100)
100 - NULL NULL
NULL 200-75 * need to this line (p_key = 200)
200 - NULL NULL
300 - 90-95 * need to this line (p_key = 300)
So, I need basically a way to restrict the values I get from the UNION of all who selects to adapt to the requirement above, hope, I was able to explain the issue I'm facing.
Any help would be greatly appreciated.
Thank you
Dpunk
Calculate a value of priority for each line according to whether the columns are null or not, stopped by this value in the game for each p_key and take the first (highest) priority. I made a more important than value_2 value_1:
Select p_key, value_1, value_2 of
(select value_1, p_key, row_number() and value_2 to the course
(p_key partition
order of cases when value_1 is null then 0 2 other end +.
cases where value_2 is null then 0 otherwise 1 end
/ / DESC
): the nurse
(your query UNION here)
)
where rn = 1
/
Tags: Database
Similar Questions
-
Need help to understand the query result
Hi gurus
I was reading one of the question here in this forum and its link is below:
I had some confusion related to this code and don't understand the logic of the out put, see query below:
Query
with sub_services as
(
Select su_seq 12323, 'HLR1' so_id, 1 seq Union double all the
Select su_seq 12323, "HLR2' so_id, seq 2 Union double all the
Select su_seq 12323, "A09" so_id, seq 3 of all the double union
Select su_seq 12333, "MO1" so_id, seq 4 Union double all the
Select su_seq 12333, "MO2' so_id, seq 5 Union double all the
Select su_seq 12333, "A09" so_id, 6 seq in union double all the
Select su_seq 12333, 'M0CR' so_id, seq 7 Union double all the
Select su_seq 12999, "LOL1' so_id, seq 8 Union double all the
Select su_seq 12999, "LOL2' so_id, seq 9 double
)
Select *.
of sub_services b
where exists (select 1 from sub_services
where su_seq = b.su_seq
and so_id = 'A09.
)
order by 2;
The query result
12323 A09 3
12333 6 A09
12323 HLR1 1
12323 HLR2 2
12333 M0CR 7
12333 4 MO1
12333 5 MO2
According to my understanding, the above query should return records in red only because of her is below command
It exists (select 1 from sub_services
where su_seq = b.su_seq
and so_id = 'A09.
but don't know why he's back 7 files, can someone help me understand the result...
It is query is functionally identical to the PL/SQL block, but much more effective.
declare
number of l_res;
Start
for line (select *)
sub_services) loop
Start
Select 1 from l_res
of sub_services
where su_seq = row.su_seq and
so_id = "A09" and
rownum = 1;
Essentially every row in the outer query are tested against him exists query. Given the correlation between two requests is based only on su_seq each line with a su_seq value returned by him is returned in the output.
Another way to think he uses instead a join condition. This query is equivalent to the query to exist
Select the main
of main sub_services
Join select (separate su_seq
of sub_services
where so_id = "A09") cond
We main.su_seq = cond.su_seq;
John
-
need help with dataProvider and HTTPService result
Hello
I am following the tutorial from flickr http://labs.adobe.com/technologies/flexbuilder2/tutorials/# and a stumbling wrt the HTTPService. The example HTTPService has id = "service" and the "Search" button called "service.send ().
The TileList is used to display the data and the dataProvider = "{service.result.rsp.photos.photo}". "
In the example, the AutoComplete even showed that service responded to the result message, but
This isn't the case for me. AutoComplete for me only shows 'resultFormat' as a possibility. Using
result, I get the error:
The result of the property possibly access not defined through a reference with static type mx.rpc.http.mxml:HTTPService. flickr1 flickr1.mxml line 11
Am I missing something?
Thank youTry 'lastResult' instead of result.
-
Need help for the release of results from a query involving the Group of
I'm working on a time-tracking application. I have a job that contains the following items: Department, System time_spent. I want that my report to display the total number of hours spent for each Department and each Department, I want to show the total hours devoted to each system.
For example:
40 hours of accounting
System 1 20.0
System 2 20.0
I wrote the following query:
< cfquery name = "getTotalHours" datasource = "mpdb2" >
SELECT deptid, system_id, sum (time_spent) as TotalHours
Tasks
GROUP BY deptid, system_id
< / cfquery >
Here is my result:
< cfoutput query is 'getTotalHours' group is "deptid" >
< h2 > #deptid # < / h2 >
< cfoutput group = "system_id" >
< ul >
< li > #system_id # #TotalHours # < /li >
< /ul >
< / cfoutput >
< / cfoutput >
Here's my question: how to accumulate the hours for each Department? I want to display the total number of hours for each Department in the < h2 > tag with the name of the service.Something like that, I usually total it myself on the fly:
-
Need help to set up voice VLAN in SG300
Hello
I spent too much time on it now and need help. I'm trying to set up a voice switch VLAN on a SG300 - 28 p. I need to charge a phone Cisco 7965 connected to a port on SG300 - 28 p to use VLAN 100, and a workstation connected to the phone to use Cisco 7965 on VLAN 101 by SG300 - 28 p. In the common Cisco IOS switches, this task is configured as follows:
interface gi25
switchport mode access
switchport access vlan 101
switchport voice vlan 100
Trying to achieve this scenario with a Cisco SG300 switch turns into a nightmare. You will have to deal with a Dynamic of VLAN voice Auto Voice VLAN mode. Then, you must have a configured trigger and activated Automatic Smartport . I tried to do this in CLI nothing helps. Cisco 7965 receives an IP address of the access VLAN on Gi15 interface, which is 101 VLAN. I need to receive an address IP of the VLAN 100.
The current configuration under Gi15 interface is as follows:
interface gigabitethernet15
activate the storm control
broadcast storm control level kbit/s 10
Storm-control include multicast
port security throw trap 60
maximum port security by 10 points
port security mode max-addresses
spanning tree portfast
LLDP-med disable
switchport mode access
switchport access vlan 101
! next order is internal
macro auto smartport dynamic_type unknown $native_vlan 101 $voice_vlan 100
Now, I don't know how the macro auto smartport dynamic_type unknown $native_vlan 101 $voice_vlan 100 command in the config, and I do not know how to remove it.
When I try to enter the command macro auto smartport type ip_phone_desktop under Gi15 interface, I get the following error message:
The $voice_vlan macro setting is not configurable by the user
It seems that the auto attendant smartport macro ip_phone_desktop can not apply the setting $voice_vlan with a value of 100. In fact, I explicitly does not use this parameter to everything in the order of macro auto smartport type ip_phone_desktop ; However, the SG300 switch knows that the voice VLAN VLAN 100, and he's trying to use this VLAN ID as the value of the $voice_vlan parameter, the macro fails.
I tried statically configure the voice VLAN on the switch SG300 using the command id of the vlan 100 voice , but I couldn't get the ip_phone_desktop macro to configure interface Gi15 correctly. Then, I removed the command id of the vlan 100 voice and obtained SG300 to learn his voice VLAN ID of UC560 connected to the SG300 through a trunk port based on the port configuration (connected to SG300) for the trunk of the next UC560:
switchport trunk vlan 101 native
switchport mode trunk
switchport voice vlan 100
Cisco-switch macro description
This is the command switchport voice vlan 100 who announces to SG300 via CDP VLAN 100 is a voice VLAN. When I run the command show vlan local VoIP on the SG300, I get the following result:
VLAN ID - VPT DSCP Source MAC address Interface
1 5 46 default ---- ---
* 100 CDP e0:5f:b9:xx:yy:zz gi28
Thus, it is clear that the SG300 receives information from UC560 via CDP in port Gi28 VLAN 100 is the voice VLAN. However, I can not always apply the ip_phone_desktop macro to SG300 Gi15 interface.
Also, I tried to set up vState ofoithis vlan auto-déclenché as well as the commands in global configuration State vlan automatic voice activated mode. Or setting changes anything view voice VLAN announced at Cisco 7965 where Cisco 7965 continues to use VLAN101 (access the VLAN assigned to the interface Gi15).
Hello telecastle,
The Macro just get in the way most of the time. A default state on the switch a user will set the id of the vlan voice with orders
(config) #voice vlan id 100
* This will create the vlan 100
VLAN, VoIP? * You can use to change your defaults for dscp and cos a long with all the other settings.
State of vlan (config) enabled automatic #voice
(config) #interface rank fa1-24
(config-if-range) #switchport trunk vlan 101 native
trunk (config-if-range) #switchport allowed vlan add 100
* This function will define the vlan native on the trunk to 101 for the data port and vlan tagged will be 101 for the voice.
CDP is enabled automatically and should learn the features of the phone and get on the phone to the vlan 101 on this port.
CDP of the UC should automatically fill in the switch of the SG. You may need to upgrade the switch to the latest firmware however. Also make sure that the DHCP server for the voice if the CPU must be configured accordingly.
Let me know if this helps.
Cisco Small Business Support Center
Randy Manthey
CCNA, CCNA - security
-
Need help to solve the problem in valueset...
Hi all
I need help in the creation of the set value.
My requirement:
I need 2 1. date settings 2. how far
When I chose the first parameter (to date) ex: 01-01-2010.
If I chose the 2nd parameter in this one, I need to display equal or superior to that date (i.e., based on the first parameter). that is, grater than or equal 1 January 2010 "this date. Not displaying does not forward then this date.
With the help of $flex$, we can do this am getting the error.
You can help me pls to it.
Thanks in advance.
Kind regards
Leelakrishna.GHello
If you use the value defined in the program settings simultaneously, the only thing to do is go to the simultaneous program settings screen, go to the parameter "Date from" and mark the field Range as low. Then go to the parameter "To Date" and mark the highest field. In this way, the system will not allow the user to enter a "Date to the ' who is older than the 'Date '. It will be useful.
Kind regards.
-
I need help my Webcam setting and put in place.
I NEED HELP MY WEBCAM SETTING AND IMPLEMENTATION. I BOUGHT IT USED
I need help my Webcam setting and put in place.
Thinking about ask you for help using Bing, Google or any search engine you want to use. Try entering "set up the webcam" in your search parameters.
Or ask for help on the Web site of the manufacturer of the webcam that you have purchased.
-
Hello
I forgot that my administration windows log password after the holidays. I have loaded down a free program called Ophcrack and had set my laptop to boot from cd 1 but I just cannot get the laptop to boot from a cd. He just continued boot from the internal hard disk.
The cd is an image and it is bootable on my desk.
The model of laptop: laptop HP ENVY m6
Product number: C2N77UA #ABL
BIOS version: F.25
Processor type: Intel Core i7-3632QM CPU @ 2.20 GHz
OS: Windows 8.1
I only did a password reset disk (I'm learning the hard way now!).
I don't want to do a "System Recovery" because I have some data on it.
I realize there are paid there password recovery tools windows, but I would like to use this 'free' program to try to break 1.
I just need help / instructions to set the bios for laptop can be started from a cd. I also tried to boot from a key USB but the laptop kept begin its internal drive.
Help, please. Thanks a ton!
Ted
Hi Ted,
You are welcome
Boot into the bios menu and go to the very section where you have disabled the Secure Boot.
Find an entry called materials and this value to Activate.
Save the changes and exit the bios.
Follow the previous procedure below:
Insert the bootable disc of Ophcrack and laptop stop.
Tap away at the esc you key start Notepad to open the Start Menu. Select boot options ( f9 ), use the arrow keys to select the CD/DVD drive and press ENTER. You can also get a prompt to "Press any key to" continuous - it if requested.
Kind regards
DP - K
-
I just reinstalled windows xp sevice pack 3 in my laptop. l need help to set up the wireless modem. My laptop is IBM ThinkPad and the modem is a construction in one. would appriciate ay help
Hi bardhiboris,
You can follow the steps from the link below: set up a wireless network:http://www.microsoft.com/windowsxp/using/networking/setup/wireless.mspx
Other links, please refer to: 10 tips to help improve your wireless network:http://www.microsoft.com/athome/setup/wirelesstips.aspx
To set up automatic wireless network configuration:http://www.microsoft.com/resources/documentation/windows/xp/all/proddocs/en-us/wlan_client_configure.mspx?mfr=true
With regard to:
Samhrutha G S - Microsoft technical support.
Visit our Microsoft answers feedback Forum and let us know what you think.
-
I need help setting up my home network - windows vista.
I need help to configure my network, I ave a laptop & hubby the computer w / dsl wireless rouuter. If I can get trhis to work, maybe we can work on the printer.
Original title: help w / home network
Hi Luvy,
Thanks for posting your query in the Microsoft Community Forums!
Looks like you need information to set up home networking on the windows vista computer.
We're here to help and guide you in the right direction.
-What is the number of brand and model of the computer?
I suggest you to return the items online help and check if it helps.
Setting up a network home
http://Windows.Microsoft.com/en-in/Windows-Vista/setting-up-a-home-network
Setting up a wireless network
http://Windows.Microsoft.com/en-in/Windows-Vista/setting-up-a-wireless-network
To install the printer on the network see Help below articles.
Install a printer on a home network
http://Windows.Microsoft.com/en-in/Windows-Vista/install-a-printer-on-a-home-network
Share a printer
http://Windows.Microsoft.com/en-in/Windows-Vista/share-a-printer
It will be useful.
Let us know if you encounter problems under windows in the future. We will be happy to help you.
-
try to set up my microsoft email in my pc. I need to respond to the need help sbout incomeing craiglist.i and out going.
I have no idea to find my server address. I use connect netgear wireless.
Hello
Looks like you need configure Windows Mail
you need to configure your e-mail account windows mail with your ISP internet service provider
They provide you with account settings you need to do
Ask them to
username
password for your access broadband account / distance with themServer of incoming POP3 mail
outgoing mail SMTP serverand here's how to configure windows mail after getting the email correct account settings
-
need help to set up Linksys printserver with verizon wifi hotspot
need help to set up Linksys printserver with verizon wifi hotspot
pfsjmhall,
Configure your wireless router to use these recommended wireless router settings, I use channel 11. I would use a new SSID to connect easier.
Then configure the Linksys print server. Find your network to give your passkey (password)
Then set up the printer, choose network and follow the instructions.
Rick
-
Need help with setting up in checkbox in interactive reports
I need help with setting up in checkbox in interactive reports, I use this statement a query
SELECT apex_item.checkbox
(
1, ROLEID,
'onchange = "spCheckChange (this);". ',
: F_ROLEID_LIST,.
':'
), del.
ROLEID, ROLEDESCRIPTION
OF EBA_ROLES
When I run it I get the following
< input type = "checkbox" name = "f01" value = "1" onchange = "spCheckChange (this); ' / > instead of the checkbox
Do I need to configure anything else
Aditya Gupta wrote:
I need help with setting up in checkbox in interactive reports, I use this statement a query
SELECT apex_item.checkbox
(
1, ROLEID,
'onchange = "spCheckChange (this);". ',
: F_ROLEID_LIST,.
':'
), del.
ROLEID, ROLEDESCRIPTION
OF EBA_ROLES
When I run it I get the following
instead of the checkbox
Do I need to configure anything else
This is one of the most frequently asked questions in this forum. Set the column attribute the text to display as Standard report column and not display text (special escape characters).
Always include the information referred to in these guidelines when you ask a question and if you use APEX 5.0, State, if you develop using the pages or the view of the component designer.
-
Need help with the property setting.
Hi all
I need a help in a drift a property setting.
We have a HP planning property definition in DRM. Sourceplan which is a defined property type with a default value as plan1.
I want to make this value of a derived property and add a parameter here inorder to fulfill my obligation i, e
If a hierarchy is to have a node name containing the string value ABC, XYZ or MNC then it HP. Type of SourcePlan must get filled with value Plan, Plan2 and plane3, otherwise it must be an empty value.
I need a help on the settings here.
Thank you
Madhu
Try this malfoy-
If)
LessThan (Length (ReplaceStr (Abbrev (), ABC, F)), Length (Abbrev (()), Integer).
Base1,
If)
LessThan (Length (ReplaceStr (Abbrev (), XYZ, F)), Length (Abbrev (()), Integer).
Plan2,
If)
LessThan (Length (ReplaceStr (Abbrev (), MNC, F)), Length (Abbrev (()), Integer).
Plane3)
)
)
Thank you
Denzz
-
Oracle Version: 11.2.0.2.0
I need assistance with the output of the query. Here is the table.
With Tbl_Nm as
(
Select 'ABC1' SYSTEM_ID, REGION 'US', 'CHI' SUB_REGION 4000 BALANCE, to_date('1-JUN-2012 10:45:00 am', 'dd-mon-yyyy hh:mi:ss am') LAST_UPD_TIME, 'A' FLAG of union double all the
Select 'PQR2', 'UK', 'LN', 2000, To_Date('1-JUL-2012 10:46:00 am', 'dd-mon-yyyy hh:mi:ss am'), has ' starting from dual Union All
Select 'ABC1', 'IND","MAMA", 3500, To_Date('1-AUG-2012 11:47:00 am', 'dd-mon-yyyy hh:mi:ss am'), 'A' from dual Union All
Select "LMN3", "US", "NJ", 2500, To_Date('1-SEP-2012 09:49:00 am', 'dd-mon-yyyy hh:mi:ss am'), 'A' from dual Union All
Select "PQR2", "UK", "MC", 2600, To_Date('1-OCT-2012 04:45:00 am', 'dd-mon-yyyy hh:mi:ss am'), 'A' from dual Union All
Select 'ABC1', 'US', 'NY', 3200, To_Date('1-OCT-2012 06:45:00 am', 'dd-mon-yyyy hh:mi:ss am'), has ' starting from dual Union All
Select "LMN3", "UK", "BT", 2400, To_Date('1-NOV-2012 07:45:00 am', 'dd-mon-yyyy hh:mi:ss am'), has ' From Dual
)
Select * from tbl_nm
I need the output below.
PQR2 UK MC 2600 1 OCTOBER 2012 04:45
ABC1 US NY 3500 October 1, 2012 06:45
LMN3 UK BT 2500 November 1, 2012 07:45
The need the disc according to this system_id flagged as "A". But if the last disc of 'd' then it must show that the amount, but the file should be displayed in 'A '.
I've tried a few and got stuck. Help, please. Not able to get a balance '.
This question is a bit similar to needing help with a query result
With Tbl_Nm as
(
Select 'ABC1' System_Id, region 'US', 'CHI' Sub_Region, 4000 balance, To_Date('1-JUN-2012 10:45:00 am', 'dd-mon-yyyy hh:mi:ss am') Last_Upd_Time, 'A' flag of double Union All
Select 'PQR2', 'UK', 'LN', 2000, To_Date('1-JUL-2012 10:46:00 am', 'dd-mon-yyyy hh:mi:ss am'), has ' starting from dual Union All
Select 'ABC1', 'IND","MAMA", 3500, To_Date('1-AUG-2012 11:47:00 am', 'dd-mon-yyyy hh:mi:ss am'), 'A' from dual Union All
Select "LMN3", "US", "NJ", 2500, To_Date('1-SEP-2012 09:49:00 am', 'dd-mon-yyyy hh:mi:ss am'), 'A' from dual Union All
Select "PQR2", "UK", "MC", 2600, To_Date('1-OCT-2012 04:45:00 am', 'dd-mon-yyyy hh:mi:ss am'), 'A' from dual Union All
Select 'ABC1', 'US', 'NY', 3200, To_Date('1-OCT-2012 06:45:00 am', 'dd-mon-yyyy hh:mi:ss am'), has ' starting from dual Union All
Select "LMN3", "UK", "BT", 2400, To_Date('1-NOV-2012 07:45:00 am', 'dd-mon-yyyy hh:mi:ss am'), has ' From Dual
)
Select System_Id, region, Sub_Region, Balance, Last_Upd_Time of Tbl_Nm T1
where t1. Last_Upd_Time = (select max (Last_Upd_Time) in the Tbl_Nm T2 where T1.) SYSTEM_ID = T2. SYSTEM_ID)
So maybe you'd then
ORDER BY DECODE(flag,'D',9,1) ASC...
to get the Ds at the end of the list.
or
ORDER BY CASE WHAT flag = has ' (your other filters) AND then 9 or 1 end CSA,...
HTH
Maybe you are looking for
-
My goal is to watch a movie in a small window of Firefox (upper-left 1/3 of the screen) while continuing to work in my other competent the remaining portion of the screen.
-
I saw the latest answers on fixing this problem. Some say that HP allows possibly f1 - f12 keys. Despite this, I brought this laptop last Christmas 15. That's the problem, Microsoft installed some updates recently, since then the f2 & f3 for bbright
-
Computer ze2315us Pavilion laptop memory upgrade
I have install 2 GB of ram in the system, and now it crashes at startup, after talking with a technician in Kingston, he said that my system could a maximum of 1 GB, 2 x 512. My question is there a flash update or a way to change the max memory in th
-
Sends data to a VI to the other
My test application consists of several VI. One of them is just to enter/modify test information, for example the tester name, date, HAD model names and numbers etc. Another is for entering the data of test equipment (serial numbers, calibration due
-
Can I put a reminder on a line on a canvas print?
Can I put a reminder on a line on a canvas print? How can I do? A few examples? I want to click on the line and a sign to appear, but I don't know how this thing of a reminder for the line of code. My canvas: Test_2 = NewCtrl (panelHandle, CTRL_CANVA