Update statement conditioned on two columns but for certain 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_1I want to perform an update as seen below
Update 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 something 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_1Thanks in advance!!!
Banner:
Oracle Database 11g Release 11.2.0.2.0 - 64bit Production
PL/SQL Release 11.2.0.2.0 - Production
"CORE 11.2.0.2.0 Production"
TNS 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 would be
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 does lead me to question whether it is a good idea to store this derived data
Edited by: 3360 on Nov 8, 2011 10:14 AM
Similar Messages
-
Im trying to update my iphone with ios 5 but, for some reason its not giving me the option to do it? i've restored my phone once like it says do on the website and it hasnt done it? what can i do ?
Are you sure you have a 3GS and not a 3G? The 3G cannot be updated to iOS5. What version are you on now?... Settings > General > About > Version
-
My software update states "an error occurred while checking for the update?
Are you doing on the device under Settings or in iTunes? Try updating through iTunes if you can.
-
I have updated my IPhone 4s to ios6, but for some reason it didn't install Siri with the update, is there any way I can install it onto my IPhone without jail breaking the phone?
Macca_astles01 wrote:
It is an iPhone 4s, it has voice control but it's not Siri, is there any way I can install it?
It cannot be installed. It comes pre-installed on every iPhone 4S and later. Maybe it was disabled under Settings > General > Restrictions.
Courcoul wrote:
Wasn't SIRI one of the gee-wiz doodads introduced with iOS 6? Cause my boss' 4s w/iOS 5 certainly does NOT have it. And on my i5, the Spanish-speaking SIRI I got turned out female, with all the foibles and vicissitudes....
iOS 6 only added support for the 3rd generation iPad. It was always on the iPhone 4S. Then the same goes for your boss: Maybe disabled in restrictions, or maybe actually an iPhone 4. -
An update statement to use cumulative columns from the previous record
I need to create a update statement which updates a record based on a column from previous record and its column where they are grouped by another columns and ordered by date in ASC. Note that I need answer from SQL 2005+.
Suppose I have records:
TransactionID ProductID TransactionDate Quantity QuantityOnHand
1 1 1/2/2014
2 ? 2
2 1 1/3/2014
3 ? 5 = 3+2
3 1 1/4/2014
1 ? 6 = 5 + 1
4 1 1/5/2014
9 ? 15 = 6 + 9
I wrote this statement but did not work:
UPDATE it2 SET it2.QuantityOnHand =it2.Quantity + ISNULL(it1.QuantityOnHand,0)
FROM IT it1
LEFT JOIN (SELECT TransactionID,ProductID, Quantity,QuantityOnHand FROM IT GROUP BY ProductID ORDER BY TransactionDate) it2 ON It2.TransactionID>it1.TransactionID
WHERE It2.ProductID=it1.ProductID
This means update the record and get the QuantityOnHand from its previous record if any grouped by the ProductID that are ordered by TransactionDate. Note that in this example there is only one product ID. Here the QuantityOnHand column should be updated
and TransactionDate is in ordered!
Mike
DDL:
CREATE TABLE [dbo].[IT](
[TransactionID] [int] NOT NULL PRIMARY KEY,
[ProductID] [int] NULL,
[TransactionDate] [datetime] NULL,
[Quantity] [float] NULL,
[QuantityOnHand] [float] NULL
) ON [PRIMARY]
DML:
INSERT INTO [dbo].[IT] VALUES (1 ,1,'1/2/2014',2,NULL)
INSERT INTO [dbo].[IT] VALUES (2,1,'1/3/2014',4,NULL)
INSERT INTO [dbo].[IT] VALUES(3 ,1 ,'1/4/2014' ,2,NULL)
INSERT INTO [dbo].[IT] VALUES(4 ,1 ,'1/5/2014' ,9,NULL)Hi
please replace this text (which is not records but just text, and therefore we can not query it):
TransactionID ProductID Quantity QuantityOnHand
1 1
2 ? 2
2 1
3 ? 5 = 3+2
3 1
1 ? 6 = 5 + 1
4 1
9 ? 15 = 6 + 9
with a DDL+DML queries to help us help you.
>> DDL+DML are queries to create your relevant table and a query to insert the sample data.
Thanks
[Personal Site] [Blog] [Facebook] -
How to search two columns and return a value in the same row to a cell?
Identification
Diameter
Soak
3" Tank (inches/kft)
AWG
mils
Code
Strands
Shield
Conductor
Insulation
Semi-Con
Days
SD
Injection
Soak
Total
2
175
00
7
External
0.288
0.692
0.752
60
0.4
3.6
20.0
23.6
2
220
00
7
External
0.284
0.764
0.864
75
0.4
3.6
20.0
23.6
2
260
00
7
External
0.284
0.844
0.944
90
0.4
3.6
21.8
25.4
2
320
00
7
External
0.288
0.964
1.064
110
0.4
3.6
24.3
27.0
2
345
00
7
External
0.288
1.014
1.114
115
0.4
3.6
25.6
29.2
Length
3"
4"
AWG
mils
Soak
SD
Injection (3")
Injection (4")
650
2
320
I want to input two values, AWG and mils and return the value in the Days column.
In the instance of what I am showing .... AWG=2 AND mils=320 so Soak=110 ....
I want to search the columns (AWG) AND (mils) to return a value in the column (Days) for that row into cell H10 (Soak) ...
So far I have toyed with LOOKUP, INDEX and MATCH ....SCW,
I'm sure there is a clever way to cascade functions to avoid adding an auxiliary column in your practice table, but to me it wouldn't be worth the aggravation. I would add a column that concatenates Columns A & B, AWG & mils. This column can be anywhere and would be Hidden. Let's say your new column is Column N.
In Column N, fill the body rows with:
=A&"-"&B
As good Numbers programming form would indicate, let's name the Practice Table Practices and only put the practices in that table. In another table where you do the lookup, let's call it Program, we will have the calculation/lookup.
Based on your example, I'd guess that AWG may be in Column D and mils in Column E of your Program table, and the Soak lookup in Column F. If I'm wrong, adjust the column id.
In Column F, write:
=OFFSET(Practices::I$1,MATCH(D&"-"&E, Practices::N,0)−1, 0)
The hyphen in the concatenated representation of the combination of AWG and mils is just tp make it more readable.
As I'm sure you know, you could use other approaches, but since I had you put your aux column at the end of your Practices table, OFFSET with MATCH is a clean approach. INDEX could be used too.
Here's an illustration:
Regards,
Jerry -
Split calcutated keyfigures itnto two columns depending on their value
Hi everybody
I have the following request:
During runtime of a query I calculate the difference between two values (keyfigures). In another column I should show the sum of those differences if they are lower than X (lets say lower thant 2) and in a third column the sum of those values if they are greater than X (lets say greater equal 2). But and this is important I only have to show the overall sum of it. There is no possibility to show every single entry of the data as it is over a million records.
01: type
02: contract
03: sum1
04: sum2
05: difference between sum1 and sum2
06: differences ge 2
07: differences lt 2
Example Data:
01 * 02.* 03 * 04
A * 1 * 20 * 19
A * 2 * 50 * 48
A * 3 * 10 * 6
B * 4 * 9 * 7
B * 5 * 25 * 24
so for type A the differences are 1, 2 and 4 and for type B the differences are 2 and 1. So in the result lne I should have for A a columne that shows 1 for the difference lower than 2 and in the other column 6 for the two differences that are greater than 2 etc.
what the report should show:
001 003 004 005 006 007
A * 80 * 73 * 7 * 6 * 1
B * 34 * 31 * 3 * 2 * 1
How can I realise this splitting of the calculated keyfigure into two columns? The X is a Variable on the selection screen so the user can select how he wants the values to be splitted.
Can I get the keyfigures to behave like this or do I have to do the calculations already during the dataload and save the difference as an infoobject and use it as characteristic in the query? I would like to avoid this if possible.
Thanks for your ideas and help!
Have a great day
best regards
ChristopheHi,
Yes ofcourse you will get this in query designer
suppose i have data like
salary
10
20
30
40
50
now i want to split this into 2 coloumns like >25 into one column <25 into another column
first salary
10
20
30
second salary
40
50
in first column take (salary < 25)*salary
in second column take (salary > 25)*salary
why we are multiplying means > value gives 1 if it is ok and 0 if it not ok in order to get data we multiply with salary.
goto query properties suppress zeroes.
Assign points if it helps,
thanka,
pavan. -
Conditionally Formatting One Column Based On The Value of Another Column
I have the following requirement:
I have 2 columns in a report showing Actual Sales & Budget Sales each year. I am using a bar chart to show the different values for these 2 columns.
I need to conditionally format the column "Actual Sales" so that if it is less than the "Budget Sales" it will appear in red, and green if "Actual Sales" is greater than "Budget Sales." So in a nutshell,
CASE WHEN "Actual Sales" < "Budget Sales" THEN
RED
ELSE
GREEN
END
Thoughts anyone?CASE WHEN (COL1 - COL2) < 0 then Red else Green end
regards
John
http://obiee101.blogspot.com -
Different measures use same source column but gives different values in SSAS project
I've inherited a SSAS project. I'm currentlig gaining knowledge, but do not understand this: There are 4 measures that get data from same source table and column. Example measures:
[Started]
[Processing]
[Processed]
[Finished]
All of them gets data from a table (view), and a column "Event_count" with just value 0 in each row. Usage of the measure is "Count of non-empty values".
Correctly all of these measures gives different values, but I don't understand how since they all go against the same source column. I thougt maybe they were defined in Calculated measures, but nothing there. Where or what else could be affecting this behavior?
Bonus information (problem): One of the measures is returning blank/empty, which is why started with this research at all.
Help anyone?
regards .rHi ,
I would ask if all the measures are under the same measure group ? It is important to know, since in the dimension usage we are creating relationships between dimensions and measure
groups .
Did you try the delete all the calculation's code and leave only the " CALCULATE ; " part ? Do the values change after deploying the slim script ?
Are all properties the same ? defaults & caching ?
Regards, David . -
PGP Whole disk Encryption but for Windows Partition only ?
Hi,
Slightly unusual situation here. I want to use my MacBook Pro at work and home. OSX at home and XP at work. Now at work they have a strict policy of only allowing computers on the network with PGP Whole disk Encryption. I've looked into this and there doesn't appear to be a way of setting this up via bootcamp because PGP makes use of MBR which as far as I know bootcamp doesn't use and PGP themselves say bootcamp isn't supported.
Looking around the web there are various articles about tripple/quad booting Mac systems not using bootcamp but things such as Grub or reFIT. I'm wondering if there is a way of using this boot technique but using the partition option when installing PGP for windows and only setting it up on the defined windows partition.
Has anybody tried this or have alternatives ?
Thanks in advance
SteveHi Steve:
Windows has a boot manager built in. Windows can be installed on a logical NTFS partition, the boot
manager can sit on a tiny fat or fat32 primary partition. I have used this arrangement on my PC's
many times. I have not tried it on a Mac, but it should work. You will need to have some working
knowledge of partitioning to pull it off.
I don't know how PGP designed their software, but it should support this arrangement, unless they
have some cheesy engineering design built into their software that would prevent it from working.
The windows boot manager has been with NT from the beginning. It is not rocket science, NTLDR
sits in the usual spot reserved for system boot files, the boot ini file tells NTLDR what partition
the /windows/system32/ntoskrnl.exe is on and NTLDR passes the ball to ntoskrnl and away
she goes if everything is Kosher. Windows boot manager can boot other OS's as well.
Be aware though that windows may assign a drive letter to the windows installation other than
"c" (usually "d" of "f". That doesn't keep anything from working though.
Kj -
Import-csv how to make powershell ignore a line in a csv file if a column contains a certain value
Basically I got a very basic script that uses a csv file to input values needed to remove people from a distro list. That part is working fine. I'd like to add to it's functionality so it can look at values in a certain column, and if any of those certain
values are present, I want powershell to skip that line and not process it. For instance I have a column in the csv called Group. If I have a listing under Group that says ABC I want the script to skip that line and not try to process it. What could I insert
into the script to acheive this?You're welcome. You can add to the if test with -and:
Import-Csv .\groups.csv | ForEach {
If ($_.Group -ne 'ABC' -and $_.Group -ne 'DEF') {
Write-Output "Group is $($_.Group)"
Write-Output "Name is $($_.Name)"
Output:
Group is GHI
Name is Show Me
groups.csv:
Group,Name
ABC,Skip Me
DEF,Skip Me Too
GHI, Show Me
Don't retire TechNet! -
(Don't give up yet - 13,085+ strong and growing) -
Detail page only for certain values
I have a page that searches a few tables.
its a overall search, but there are records we dont want to
allow anyone to
edit based on a value.
So my question is... i have a results page which is already
setup to display
all records found.. with a link(go to detail page) how can i
code it so if
any of the results have a certain value that link is not
available?
Example
Name Phone Email
Contact Details
John 555-555-5555 [email protected] Yes View
Dave 222-333-4545 [email protected] No
Jess 854-896-7852 [email protected] Yes View
Using ASP, SQL2005 and DW8Can anyone help with this one?
I just want to disable the link to the detail page if the
value for Contact
is NO then disable Details link
Using ASP, SQL2005 and DW8
"Daniel" <[email protected]> wrote in message
news:f2d35r$806$[email protected]..
>I have a page that searches a few tables.
>
> its a overall search, but there are records we dont want
to allow anyone
> to edit based on a value.
>
> So my question is... i have a results page which is
already setup to
> display all records found.. with a link(go to detail
page) how can i code
> it so if any of the results have a certain value that
link is not
> available?
>
> Example
>
> Name Phone Email Contact Details
> John 555-555-5555 [email protected] Yes View
> Dave 222-333-4545 [email protected] No
> Jess 854-896-7852 [email protected] Yes
> View
>
>
>
> --
> Using ASP, SQL2005 and DW8
> -
User Permissions for certain pages only possible?
I have a client interested in BC but I need to know if they can assign user edit permissions for certain pages to certain users? For example lets say they have pages A B C D E F and they want Tom to be able to edit A B & C but not D E F and they need Sally to be able to edit D E & F but not A B & C. Is this possible with BC?
Hi,
The option is to use and set a workflow for "content approval" to each page.
Site settings -> manage workflows
"You can attach a workflow approval process to any web page or template. When an approval is attached to a web page or template, then all changes must be approved by predesignated users of the system before they go live. To attach a workflow to an item, click on the 'More Options' link and choose a workflow."
Site manager -> pages -> more options
Hope this helps!
-Sidney -
Help: matrix report grid lines missing for null values only on server side
Hi,
I created a matrix report in pdf format. The output in great when run through report builder locally, it renders all necessary details. However, after the report being moved into AS server, the report does not show grid lines for null values.
It looks to me this has something to do with configurations and hope someone know what needs to be done.
Any suggestions are greatly appreciated.
JimmyThanks for replying.
DESFORMAT is PDF.
There should be a fix as I had same issue with same Oracle version at my previous company. DBA fixed the issue on AS server.
I found your post on 09/28/2010 with a link to patch set: Re: Null value fields disappear in pdf output format
We worked out with the work around without install the patch.
Jimmy
Edited by: WJHORA on Sep 8, 2011 2:16 PM -
Disabling cprojects alerts for certain users only
Hi
I need that no email alerts are sent to certain roles/people who have authorizations in cprojects. There are numerous alerts sent as email for any change of dates, thresholds etc. I need to disbale any email being sent in this for certain users.
How can it be done?
Regards
SenthilHi Senthil,
Would you please check the following
Evaluations -> Business Add-Ins (BAdIs) -> Change Alerts from Severities in cProjects
related method is CHANGE_ALERTS_OF_PROJECT, which has a change parameter:
CT_LANGUAGE_OF_RECIPIENT. You can apply your own logic to remove some recipient of the table, so that they do not get the e-mail.
Never tested, please check it out.
Kind regards,
Zhenbo
Maybe you are looking for
-
MAC OS 10.5.8 Combo update installation probs
Hi!! I'm trying to update my mac with the new software update, but unfortunately, it can't seem to finish installing. im stuck in the "configuring installation" part. i left the computer for two hours hoping that it would continue with the installati
-
MBP not detecting video camera via FireWire 800
Hey all, I bought a MacBook Pro late 2008 mainly for video editing. Also, I purchased a 3rd-party FireWire cable because Apple doesn't distribute them here in Singapore (-_-). I've tried many times to connect my 2 video cameras to my Mac and NONE of
-
Hello there, I am totally green in web development. my goal is to, for the user will input a date range from and to and will out put the records in the intranet when they press a button. However, the good news is: I have experience in programming. I
-
I've been having an odd issue with Safari that been happening more recently over the past few days, but has been there for a while. If I'm browsing in Safari and I click somewhere else, such as on a finder window, the finder window would come into fo
-
Apple TV in a multiple account household
So almost finished uploading all of my music to iTunes Match and looking to now upgrade my fiancees apple account however one problem... We have an apple tv (second gen) which is currently linked to my apple ID and understandably she would like her c