How to update this? please
Dear all expert
I have 2 tables 'CUST_AND_MKT' and 'CUST_SUMMARY' as below
select * from cust_and_mkt;cust_id mkt_id sale_volume
C0001 M0124 10,000
C0001 M7208 4,000
C0001 M0010 1,000
C0444 M0080 340,000
C0444 M1200 100,000
C0878 M0505 450,000
select * from cust_summary;cust_id cust_name mkt_id total_volume
C0001 JOHN EDWARD <null> 15,000
C0444 SARAH LANE <null> 440,000
C0878 TOMMY E.CLEK <null> 450,000I want to assign marketing who has a maximun sale_volume
in each customer to take care customer. My problem is how
to write SQL command to update mkt_id from 'CUST_AND_MKT'
to 'CUST_SUMMARY' as below
cust_id cust_name mkt_id total_volume
C0001 JOHN EDWARD M0124 15,000
C0444 SARAH LANE M0080 440,000
C0878 TOMMY E.CLEK M0505 450,000Thank you all for your kindness
JOE-Thailand
SQL> select * from v$version;
BANNER
Oracle Database 10g Enterprise Edition Release 10.2.0.2.0 - 64bi
PL/SQL Release 10.2.0.2.0 - Production
CORE 10.2.0.2.0 Production
TNS for HPUX: Version 10.2.0.2.0 - Production
NLSRTL Version 10.2.0.2.0 - Production
SQL> create table cust_summary
2 as
3 with t
4 as
5 (select 'C0001' cust_id, 'JOHN EDWARD' cust_name, cast(null as varchar2(20)) mkt_id,
6 15000 total_volume from dual union all
7 select 'C0444', 'SARAH LANE', null, 440000 from dual union all
8 select 'C0878', 'TOMMY E. CLEK', null, 450000 from dual
9 )
10 select * from t;
Table created.
SQL> create table cust_and_mkt
2 as
3 with t
4 as
5 (select 'C0001' cust_id, 'M0124' mkt_id, 10000 sales_volume from dual union all
6 select 'C0001', 'M7208', 4000 from dual union all
7 select 'C0001', 'M0010', 1000 from dual union all
8 select 'C0444', 'M0080', 340000 from dual union all
9 select 'C0444', 'M1200', 100000 from dual union all
10 select 'C0878', 'M0505', 450000 from dual
11 )
12 select * from t;
Table created.
SQL> select * from cust_summary;
CUST_ CUST_NAME MKT_ID TOTAL_VOLUME
C0001 JOHN EDWARD 15000
C0444 SARAH LANE 440000
C0878 TOMMY E. CLEK 450000
SQL> select * from cust_and_mkt;
CUST_ MKT_I SALES_VOLUME
C0001 M0124 10000
C0001 M7208 4000
C0001 M0010 1000
C0444 M0080 340000
C0444 M1200 100000
C0878 M0505 450000
6 rows selected.
SQL> l
1 merge into cust_summary
2 using (select cust_id, max(mkt_id) keep(dense_rank first order by sales_volume desc) mkt_id
3 from cust_and_mkt
4 group by cust_id
5 ) cust_and_mkt
6 on (cust_summary.cust_id = cust_and_mkt.cust_id)
7 when matched
8 then
9* update set mkt_id = cust_and_mkt.mkt_id
SQL> /
3 rows merged.
SQL> select * from cust_summary;
CUST_ CUST_NAME MKT_ID TOTAL_VOLUME
C0001 JOHN EDWARD M0124 15000
C0444 SARAH LANE M0080 440000
C0878 TOMMY E. CLEK M0505 450000For more information check the following link.
Merge Oracle10g
http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_9016.htm#SQLRF01606
Keep Analytics
http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/functions056.htm#SQLRF00641
Merge Oracle9i
http://download.oracle.com/docs/cd/B10501_01/server.920/a96540/statements_915a.htm#SQLRF01606
Hope that helps.
Regards
Raj
P.S : If you are using oracle 9i then when not matched is compulsory and you need to include that clause. For more information check the link on merge statement for Oracle 9i
[Edit : ] Added Oracle version and caveat for merge when using oracle 9i
Message was edited by:
R.Subramanian
Similar Messages
-
Can someone please just help me figure out how to update this stupid phone(iPhone 4)without losing anything? I somehow have more than one Apple ID on this,but I just want my music and my pictures to stay and I'm terrified of losing these things. I have a lot of music from old CDs on here,and for some reason I can't even transfer them manually onto my computer. I'm not tech savvy whatsoever. Someone please help,having my music is the the whole reason I still have this phone.
First read about back http://support.apple.com/kb/ht1766
Then read on how to transfer photos to your computer http://support.apple.com/kb/ts3195
Then
UPDATING iOS
Over the air updating of iOS needs iOS 5 or later so unless you have iOS 5 or later you will not see updating in setting
The following link explains how to update http://support.apple.com/kb/HT4972
This link explains how to update using wireless http://support.apple.com/kb/HT4623
This explains how to transfer purchases to your computer http://support.apple.com/kb/ht1848 -
Hi I'm trying to update my iPhone 4 to ios7 through iTunes , when I click update it tells me to change media sync options to make more storage available .... Anyone know how I do this please ... Thanks ,Helen
You're out of space. Do you sync music to your phone? If so, try syncing it over in 128kb which will save a lot of room. Option is right in front of you in iTunes when you plug phone in.
-
Some calendars in iCal appear corrupted (ie have red exclamation mark by them) but are still OK on iPhone. If I sync, will the calendar data on the phone restore info on the desktop iCal or will I lose that as well? Or could I back up the calendars on my iPhone somewhere and then import them into iCal? any other ideas for how to sort this please? it's driving me mad. thanks.
I don't think there will be a solution to this. Exchange 2003 just isn't supported.
-
Final Cut Pro X keeps freezing when sharing my work to You Tube, it does about 90% of the upload and then seems to get stuck. Any ideas on how to resolve this please?
this is a perfect question to ask the users in the FCP X forum. Good luck. https://discussions.apple.com/community/professional_applications/final_cut_pro_ x
-
Can't seem to change the Document Properties > Advanced > Reading Options in a Form that was created in Adobe LiveCycle. This option has been "greyed" out - anyone know how to update this to English so I can pass Accessibility Testing?
LiveCycle forms use a very different approach to create a PDF form than Acrobat and that approach makes many features for processing PDFs non-functional.
You might want to ask this question in one of the LiveCycle product forums. -
Hi,
After writing into serial port, the same message gets bounced back into the Inqueue also. If anyone know how to avoid this, please reply.
Thanks,
GaneshIf you disconnect the cable going to the serial device, do you still get the echo? If so you have something going on in the port setup. If disconnecting the cable stops the echo then the device you're talking to is doing it - which would be my bet. One thing to check is whether this might not be normal operation. I have seen devices that if a command was successful, it simply echo'd back the command string you had sent. Also many serial devices have setting for specifying whether they are to echo commands.
Mike...
Certified Professional Instructor
Certified LabVIEW Architect
LabVIEW Champion
"... after all, He's not a tame lion..."
Be thinking ahead and mark your dance card for NI Week 2015 now: TS 6139 - Object Oriented First Steps -
'''''
I have my home page set to Google. When I open a new tab I want it to also open as Google instead of tabbed browsing. Would you please email me how to do this, please? Thank you!'''''
Kind regards,
Ronny T. GallichioYou can look at one of these extensions:
* NewTabURL : https://addons.mozilla.org/firefox/addon/2221
* New Tab Homepage : https://addons.mozilla.org/firefox/addon/777 -
I have downloaded a series of prison break but 3 episodes are saying "you do not have permission to access the requested resource" and "this episode can not be downloaded at this time" any idea how to fix this please??
I got this error with my iPad 3, my wife's iPhone 4, but not with my iPhone 4s.
-
Having worked on a photograph in Pages 08 document I cannot find a way of transferring it to the desktop, iPhoto or Photoshop. Does anyone know how to do this please.
Inspector palette > Metrics > select the image name and drag to the desktop
-
HT1222 How to update this phone ?
How to update this phone ?
If your on IOS 5 you can update thru your phone via wifi and plugged into a wall charger.
If your not on IOS 5 then plug your phone to your computer open iTunes and then update that way, itunes should automatically see that an update is needed. Suggest you backup your phone first then update. -
I have just connected my computer to my iPad to import photos to my iPad and have imported the wrong ones and wish to delete them. Does anyone know how I do this please. I am a novice at this as I have ony just acquired my iPad,
Photos that were synced from your computer using iTunes can only be deleted by de-selecting them from the folder from where they were synced - and then re-syncing.
Connect the iPad to the computer and launch iTunes.
Click on the iPad name on the left side under devices.
Click on the Photos Tab on the right.
Uncheck all of the albums that you want to remove under the Sync Photos From heading
Click on Apply in the lower right corner of iTunes
If you are using iTunes 11 and you can't see the sidebar go to View>Show Sidebar from the menu at the top. -
have an existing icloud account and I changed iphone. When I track my iphone it locates the old iphone. How to resolve this please?
Hi kitdan,
If you need to remove an old device from Find My iPhone, you may find the following article helpful:
iCloud: Remove your device from Find My iPhone
http://support.apple.com/kb/ph2702
Regards,
- Brenden -
I have an iPad mini 16g. It has started jumping through different pages of it's own accord, any ideas how to fix this please?
I recommend starting with a soft reset (pressing both home and power button until you see the apple then let go of the buttons) once you back on the home screen if you iPad still doing the same thing you may want to try a back up and restore
http://support.apple.com/kb/ht1766 to back up
http://support.apple.com/kb/ht1414 to restore -
i m not able to connect for the wifi which i have used earlier ,i m getting an error as unable to join the network how to resolve this please help me
We were able to log in this morning and all is working. You should be able to log in at any point today. Please let us know if you are having any other difficulties.
-
I have been trying to download Creative Cloud but it gets stuck half way down. Does someone knows how to fix this please?
Any hints or help will be more than appreciated.
Cheers
PanchoYou have not provided any system info nor aany other details.
Mylenium
Maybe you are looking for
-
My small company (Academic Software, Inc.) has a few educational games designed (and fairly popular) for very young (or developmentally young) children with severe disabilities. These were produced with Director 7 for Mac and for PC and I recall writ
-
Flash builder 4.7 iOS Debug Binary (IDB) component is not installed.
I get the error below consistantly. Is the IDB supposed to be part of the flex 4.6 sdk or part of an air sdk? (I've not seen it in either) Some components required to launch the application were not found. Please reinstall the AIR SDK and try again.
-
How to load xml data into a table
Hi, i am a newbie. I want to insert the data of xml file into a table. I am doing this using XSU api for java. I am using oracle 9i and jdk 1.7. I am using OracleXmlSave class. but i am getting following error. java.lang.NoClassDefFoundError: oracle/
-
How do I get my Itouch to unlock?
Unable to slide to unlock or slide to power off, unresponsive. Any suggestions?
-
Unable to open downloaded adobe xi pro trial. windows 7. please help.
this is giving me a lot of headache. there is no instruction on what to do next. nothing just happens.