Update statement conditioned to two columns, but for some values only
Hi This is my my sample data:with Table_1
as
(
select '20:00' incident_time, 'WEDNESDAY' Day, 'N' Weekend, '' Weekend_Alt from dual
union all
select '18:00' incident_time, 'SATURDAY' Day, 'Y' Weekend, '' Weekend_Alt from dual
union all
select '19:00' incident_time, 'FRIDAY' Day, 'N' Weekend, '' Weekend_Alt from dual
union all
select '11:00' incident_time, 'FRIDAY' Day, 'N' Weekend, '' Weekend_Alt from dual
)
select *
from Table_1
I want to perform an update as shown belowUpdate Table_1 tt
SET Weekend_Alt = (CASE WHEN TO_CHAR(tt.day,'fmDAY') IN ('FRIDAY AND TIME >= 19:00','SATURDAY','SUNDAY') THEN 'Y' ELSE 'N' END)
I realize the syntax is wrong but just want to give you an idea of what I want to achieve.
Final result should look like this:with Table_1
as
(
select '20:00' incident_time, 'WEDNESDAY' Day, 'N' Weekend, 'N' Weekend_Alt from dual
union all
select '18:00' incident_time, 'SATURDAY' Day, 'Y' Weekend, 'Y' Weekend_Alt from dual
union all
select '19:00' incident_time, 'FRIDAY' Day, 'N' Weekend, 'Y' Weekend_Alt from dual
union all
select '11:00' incident_time, 'FRIDAY' Day, 'N' Weekend, 'N' Weekend_Alt from dual
)
select *
from Table_1
Thanks in advance!Banner:
Oracle Database 11 g Release 11.2.0.2.0 - 64 bit Production
PL/SQL Release 11.2.0.2.0 - Production
"CORE 11.2.0.2.0 Production."
AMT for Linux: Version 11.2.0.2.0 - Production
NLSRTL Version 11.2.0.2.0 - Production
with Table_1
as
(
select to_date('01-JUL-2009 20:10','DD-MON-YYYY HH24:MI') incident_date from dual
union all
select to_date('23-MAR-2010 12:12','DD-MON-YYYY HH24:MI') incident_date from dual
union all
select to_date('25-JUL-2010 23:30','DD-MON-YYYY HH24:MI') incident_datet from dual
union all
select to_date('09-JAN-2010 08:30','DD-MON-YYYY HH24:MI') incident_date from dual
union all
select to_date('08-JAN-2010 08:30','DD-MON-YYYY HH24:MI') incident_date from dual
union all
select to_date('08-JAN-2010 20:30','DD-MON-YYYY HH24:MI') incident_date from dual
union all
select to_date('26-JUL-2010 00:00','DD-MON-YYYY HH24:MI') incident_datet from dual
)
select incident_date, to_char(incident_date,'Day'),
case
when incident_date between trunc(incident_date,'IW') + 4 + 19/24
and trunc(incident_date,'IW') + 7
then 'Y' else 'N'
end
from Table_1 t;
So your update
update table_1 tt
set weekend_alt =
case
when incident_date between trunc(incident_date,'IW') + 4 + 19/24
and trunc(incident_date,'IW') + 7
then 'Y' else 'N'
end;
But it begs the question if it's a good idea to store these derived data
Published by: 3360 November 8, 2011 10:14
Tags: Database
Similar Questions
-
Is possible to write the INSERT statement that fills two columns: 'word' and 'sense' of the file text with multiple lines - in each line is followed word that is the meaning?
Hello
2796614 wrote:
Is possible to write the INSERT statement that fills two columns: 'word' and 'sense' of the file text with multiple lines - in each line is followed word that is the meaning?
Of course, it is possible. According to what the text file looks like to, you can create an external table that treats the text file as if it were a table. Otherwise, you can always read the file in PL/SQL, using the utl_file package and INSERT of PL/SQL commands.
You have problems whatever you wantt? If so, your zip code and explain what the problem is.
Whenever you have any questions, please post a small example of data (CREATE TABLE and only relevant columns, INSERT statements) for all of the tables involved and the exact results you want from these data, so that people who want to help you can recreate the problem and test their ideas. In this case, also post a small sample of the text involved file.
If you ask about a DML operation, such as INSERT, then INSERT statements, you post should show what looks like the tables before the DML, and the results will be the content of the table changed after the DML.
Explain, using specific examples, how you get these results from these data.
Always say what version of Oracle you are using (for example, 11.2.0.2.0).
See the FAQ forum: Re: 2. How can I ask a question on the forums?
-
My creative cloud said he renewed on 21 July. But for some reason, my updates are the trials and expire tomorrow. How to run for tomorrow on my plan?
Please visit: https://helpx.adobe.com/manage-account-membership/cc-reverts-to-trial.html
I hope this helps.
-
I install the new cc2014 update, but for some reason any in my computer displays double former app and the new, but the new dose did not setup that I have in my old version! What will happen?
Thanks, I have solved this problem, simply delete the old and manually I have brand new!
-
HELLO, I TRIED TO UPGRADE TO WINDOWS 10 MONTHS NOW. MICROSOFT SAYS MY SYSTEM IS COMPATIBLE BY FAR, BUT FOR SOME REASON, THIS MODEL OF DELL DOES NOT ACCEPT IT. I HAVE A DELL STUDIO 540, X 64 BASED PC. PLEASE HELP, I REALLY WANT TO TRY WINDOWS 10.
Original title: WIDOWS 10 UPDATE
If Dell has said that it is not compatible, I wouldn't do it. Dell needs to have the drivers and software for it or it is not working properly. I would make sure you call, email or web-chat with Dell and ask them first.
If you really want to try anyway (at your own risk), you can, but I suggest that do you a full picture of backup of your computer in order to "undo" that and go back to the way you are today if something is wrong or you don't like it.
-
using outer joins if the two column is null? Use only (+)
Hi all
create the table xxc_tr_num (tl_number number, tr_no number tl_no_id);
insert into xxc_tr_num values (123,100,222);
insert into xxc_tr_num values (124,100,333);
create the table xxc_od_tab (tl_number number, tl_id number);
insert into xxc_od_tab values (123,001);
insert into xxc_od_tab values (null, null);
create table xxc_oth_tab (name varchar2 (10), number of tl_id);
insert into xxc_oth_tab values('abc',,001);
insert into xxc_oth_tab values (null, null);
Wait it out put
tr_no tl_no_id name
100 222 abc
100 333
using outer joins if the two column is null? use only please of outer joins
And I tried to use outer joins on both tl_id column but not get values and I use have County (tr_no ) > 1
Rajesh123 wrote:
Thank you Kiss it is not possible to use having clause?
You need to understand the functioning of the group. If you will not be asked this question.
Check this box
SQL> select tr_no, 2 tl_no_id, 3 count(*) 4 from xxc_tr_num a, 5 xxc_od_tab b, 6 xxc_oth_tab c 7 where a.tl_number = b.tl_number(+) 8 and b.tl_id = c.tl_id(+) 9 group 10 by tr_no 11 , tl_no_id; TR_NO TL_NO_ID COUNT(*) ---------- ---------- ---------- 100 333 1 100 222 1
See what returns the count? You have grouped according to TR_NO and TL_NO_ID. You must take into consideration the TL_NO_ID just put COUNT (TR_NO) does not increase the NUMBER of the whole group. To get the NUMBER on the whole group, I used the analytical function and did. Like this, see the number of the analytical function here
SQL> select tr_no, 2 tl_no_id, 3 count(*), 4 count(*) over(partition by tr_no) 5 from xxc_tr_num a, 6 xxc_od_tab b, 7 xxc_oth_tab c 8 where a.tl_number = b.tl_number(+) 9 and b.tl_id = c.tl_id(+) 10 group 11 by tr_no 12 , tl_no_id; TR_NO TL_NO_ID COUNT(*) COUNT(*)OVER(PARTITIONBYTR_NO) ---------- ---------- ---------- ------------------------------ 100 222 1 2 100 333 1 2
So to answer your question, yes you can't do in the HAVING clause...
-
I want to use InDesign, but for this month only! so if I pay for the "monthly plan" means that I pay for this month then the plan InDesign will end?
Hello
Please go through the Adobe - General conditions of subscription as well.
Alternatively, you can contact customer service
Hope that helps!
Kind regards
Sheena
-
My Abobe photoshop 4.0 is not compatible with my Windows 7 a mild wear. It was, but for some reason any won't work now. I thought it was time to try a new version of photoshop and some sort finished with a cloud, and apparently will have to pay for access to Photoshop elements, which is everything I wanted in the first place. Is there a way I can get out of this oblogation to $120.00 and go to Staples and buy Photoshop elements 14?
You may have to wait until Monday because of the long holiday weekend in the United States
Chat/phone: Mon - Fri 05:00-19:00 (US Pacific Time)<=== note="" days="" and="">===>
Cancel https://helpx.adobe.com/creative-cloud/help/cancel-membership.html
-or https://helpx.adobe.com/contact.html?step=ZNA_account-payment-orders_stillNeedHelp
> finished with a cloud and apparently will have to pay to access Photoshop elements
I don't know what you bought, but Photoshop Elements only not part of the cloud
Also, to install or run version 4 with Win7, did you do a RIGHT click on the program and select a compatibility mode from the option list?
-
I bought a few days on the plan (CC Photoshop + Lightroom) software Adobe Creative Photography of Amazon Cloud, but for some reason any when I try to download the software, it says that my trial period has expired, and I was not able to use it. Please help me!
Tayshag85359328 if you have an active member of the creative cloud then please see Solutions to connect, activation and errors in connection with creative cloud and applications Creative Suite. for more details on how to solve the connection failure. If you have any questions about the steps listed in the document, we invite you to update this discussion.
-
I'm seeing my favorite/recent contacts on my phone. I know that you're supposed to go to settings / mail, contacts, calendar and go to the contacts section and click on view in the app, but for some reason button that I do not have this option. Someone knows why?
Probably since iOS and iOS 9.3.x 9 there is no option, they show right here.
Get help using iCloud Contacts, calendars, or reminders - Apple Support
-
Original title: I try my computer, but for some reason any that it won't let me back. and I get an error message
Remember - this is a public forum so never post private information such as numbers of mail or telephone!
Ideas: have problems with window vista home premium
- You have problems with programs
- Error messages
- Recent changes to your computer
- What you have already tried to solve the problem
Hello Mipregunta,
Thanks for your quick response! I suggest that you try to visit the following article for steps on how to solve your problem:
http://support.Microsoft.com/kb/952272
Please let me know if this helps J
Adam
Microsoft Answers Support Engineer
Visit our Microsoft answers feedback Forum and let us know what you think -
I can get in my e-mails, but for some reason, he never lets m read them
I can get my account email, but for some reason any, that he won't let me read my emails
Hi John,.
1. what email account you use?
2. using any client e-mail (Outlook, Windows Live Mail or Webmail)?
3. what happens when you try to read the emails?
4. are you able to get any error message?
5. are you able to read email using any other computer?
6. is specific to a particular e-mail account question?
Please post with more information on this issue to get help.
-
I just got a chat session with unnecessary failure to load Adobe. I bought LR6 in September. He worked for a while. Now my develop the module is disabled and it says that I have to put the licensed software. I have my number series but for some reason any it not reactivate my software. I downloaded the software directly from Adobe. I paid for the license from Adobe. I have a serial number adobe, but nothing works.
Hi iamangryatlightroom,
Please refer to the related discussion and follow the steps to solve the problem.
Reference: Lightroom 5.5 'Module Development disabled, please renew your membership'
Let us know if that helps.
Kind regards
Mohit
-
I was going to pay for my monthly plan, but for some reason any, that I couldn't find my plan, then automatically right, I thought it had been deleted since I did not pay for my plan in due time. So I made a new plan, but now that I paid for my monthly plan twice, and well, it sucks a bit... So what to do? And can I get my money back?
For assistance, please contact our support staff:
-
I'm trying to upload my site using ftp, but for some strange reason, the ftp server box becomes red, even if the name is correct. everyone knows about this problem?
Hello
I would ask to share with you the screenshot of the box which becomes red.
Concerning
Vivek
Maybe you are looking for
-
How can I send faxes directly to the computer?
I have an Officejet Pro 8500 a HP all-in-one. My computer operating system is windows Vista home and the printer is connected wireless to my home network. I want to know how to send a fax received from the printer directly to the computer without h
-
Re: Wireless has stopped working on my Equium L40 (PSL41E)
Hi guys. With the help of my laptop wireless this morning and all was fine, then all of a sudden, it loses the connection. Tried different methods to restore the link, update driver downloaded but no luck. The wireless light on the front of the lapto
-
Hello When I optimize my FP at this time here my gauge is not in shap... any idea... ???
-
Qwest has moved my live mail windows q.com account for myqwest.com? I don't like the new Web site for my email. Is there anything I can do to get a different messaging platform without changing my email address? It is said that they do not support
-
How to increase Mins to DateTime...
Hello I have a date past say Sun may 24 18:40:00 GMT 2009 I have uncreated 10mins to this day... but unable to do so... Can someone pls help increarse the minutes in 10 minutes date... kindly help...