Combine data deletion of nulls
Hi allI have a table with data that looks like this:
Co Division Dept
1 abc 00
2 abc 01
3 abc 01020
4 abc 01040
5 abc 01060
194 abc 0001
195 abc 0005
196 abc 0060
197 abc 0101
198 abc 01021
{code}I'd like to combine the data so that the department values (0001, 0005 etc) populate the first 5 rows of the table in place of the null values. You can't tell from the formatting but values starting with '0001' in row 194 are in the Dept column. Thoughts?
Edited by: BobH90024 on Sep 8, 2008 1:30 PM
Edited by: BobH90024 on Sep 8, 2008 1:31 PM
Edited by: BobH90024 on Sep 8, 2008 1:31 PM
Edited by: BobH90024 on Sep 8, 2008 1:40 PM
Edited by: BobH90024 on Sep 8, 2008 1:40 PM
Hello
Here's a query that does what you requested:
WITH qn AS
( -- Begin qn, query with divison_num and dept_num
SELECT company
, division
, dept
, ROW_NUMBER () OVER
( PARTITION BY company
ORDER BY division NULLS LAST
) AS division_num
, ROW_NUMBER () OVER
( PARTITION BY company
ORDER BY dept NULLS LAST
) AS dept_num
FROM table_x
) -- End qn, query with divison_num and dept_num
SELECT div_s.company
, div_s.division
, dept_s.dept
, div_s.division_num AS num -- Not needed
FROM qn div_s
JOIN qn dept_s
ON div_s.company = dept_s.company
AND div_s.division_num = dept_s.dept_num
WHERE div_s.division IS NOT NULL
OR dept_s.dept IS NOT NULL
ORDER BY company
, div_s.division_num
;
You did not ask the last column (num), and you probably don't want it displayed, so feel free to remove from the SELECT the main query clause. I've included just to help illustrate this query works.
You want to combine data from two different rows in the same table (for example, the line where division = 123 and the row where dept = 'mno') together on the same line of the result. This looks like a self-join, which is exactly what makes the main request.
The self-join is made between two copies of all results of SB: one to get the division (div_s) and the other for the dept (dept_s).
This query paris first division (in numerical order) with the first dept (in alphabetical order). I used the analytical ROW_NUMBER function to number each line according to the division and once again according to dept, to make the self-join. NULL values come after the actual values, as you requested.
To test this, I used "abc company" you have published and added three more companies to test the special cases:
COMPANY DIVISION DEPT
---------- ---------- ----------
abc 123
abc 234
abc 345
abc mno
abc xyz
foo bar
nada
nada
okay? 100 zebra
okay? 200 ant
"foo" is a company that's more than the divisions (1 > 0). You said that this can happen.
"nada" is a company that has lines where Division and dept are both NULL. As you can see, there is nothing in the result set to indicate that this company still exists. You didn't say this can happen, and I don't know if that's what you want to do in this situation.
"OK?" is a company with lines that have already have division and Dept. All data are displayed in the result set, but not necessarily as it is in the table. (For example, in the table, division = 100 is paired with dept = "Zebra", not with dept = 'ant'.) You did say that it can happen.
Here are the results of this broader set of test data:
COMPANY DIVISION DEPT NUM
---------- ---------- ---------- ----------
abc 123 mno 1
abc 234 xyz 2
abc 345 3
foo bar 1
okay? 100 ant 1
okay? 200 zebra 2
The situations illustrate companies 'nada' and 'OK?' may not be possible in your actual tables.
If these situations are possible and you don't like how this request manages them, I am confident that the problem could be solved. Right after the results you want instead.
Tags: Database
Similar Questions
-
correct handling of foreign keys in unique constraints for operations ON DELETE SET NULL
During my troubleshooting at a client site, I came across an interesting setup where I would like to ask your opinion.
Consider two tables ADTB and TBLB.ADTB:
INT COLA1
COLA2 INT
TBLB:
COLB1 INT
COLA2 is COLB1 as a foreign key ON DELETE SET NULL value.
COLA1 and COLA2 are combined into a UNIQUE for the BATTERY constraint.
I have two records of TBLB:
(1)
(2)
and two DRUM recordings:
(1, 1)
(2, 2)
so far, all the constraints are valid.
During my research, I learned that I can not put COLA2 null in ADTB for two lines at the same time:
TBLA UPDATE set COLA2 = NULL where COLA1 = 1;
-> OK
TBLA UPDATE set COLA2 = NULL where COLA1 = 2;
-> VIOLATED UNIQUE CONSTRAINT
Unfortunately, it's something my application needs, anyway. In order to get this resolved, but I try to understand, what would happen if I:
REMOVE THE TBLB;
?
It should set COLA2 in ADTB "Null" on the two lines, which is not allowed due to the UNIQUE CONSTRAINT.
Can someone shed light on this issue? Thank you.
Yours,Ronny
Unfortunately, as you say, you can't not NULL values in such a unique constraint. It would be the same as if you had a composite primary key and try to allow one of the columns will be null in several rows with the same value in the other column. NULL is treated as an "unknown" value, it is possible that it could be the same value (it may or may not be, but Oracle does not know), so it must assume that it might be and that's why treat it as if there is the potential for a duplicate... so it's not unique.
In short, do not allow null values in your unique constraints.
The default is in the drawing, not in the way that Oracle is the treatment. Fix the design if you do not have NULL values.
In terms of relational database design, it seems that you are trying to transform the 1:M relations M:M relations, and which requires an intermediate table if you have M:1 and 1:M between 3 tables instead.
-
Create the query by combining data from DBSS_Data_Model and HostModel
Hello
I am trying to create a dashboard with the host server list and instances of SQL Server running on the host.
And I am interested in creating a query by combining data model of data in SQL Server (DBSS_Data_Model) and the host (Hosts) data model, say: which connects DBSS_SQL_Server_Host and host.
I wonder if there is way to do it?
Thank you
Mark
Something like this function should work:
def physicalHost = nullqueryStatement = server.QueryService.createStatement("(Host where name = '$hostName')")result = server.QueryService.executeStatement(queryStatement)objs=result.getTopologyObjects() if (objs != null && objs.size() > 0) { physicalHost = objs.get(0)}return physicalHost
When the input parameter "hostName" is DBSS_SQL_Server_Host.physical_host_name
Kind regards
Brian Wheeldon
-
Cipher.exe to overwrite the data deleted in Windows works with Windows Vista?
Cipher.exe to overwrite the data deleted in Windows works with Windows Vista? He worked under Windows 2000, but not sure about Vista! Otherwise Vista contains a command to clean free space HDD?
Hello
you need 3 of third party programs to clean free hard drive space
For your question:
always check the compatibility of vista programs on the link below
http://www.Microsoft.com/Windows/compatibility/Windows-Vista/default.aspx
If a program is compatible with vista you can try right click on the setup.exe, and then selecting run as administrator
It is not compatible with vista, you can try running it in a previous operating system mode
This does not work for all programs
read the information below
http://www.howtogeek.com/HOWTO/Windows-Vista/using-Windows-Vista-compatibility-mode/
-
Suddenly the column Date deleted to the trash has been replaced by the update
original title: Recycle bin sort order problem
Suddenly the Date deleted in Recycke Bin column was replaced by update. I am more able to sort items deleted in the trash by deleted date.
Suddenly the Date deleted in Recycke Bin column was replaced by update. I am more able to sort items deleted in the trash by deleted date.
Open the Recycle Bin > menu toolbar ( not ) see > sort by > more > scroll to find Date removed,click on it > move the button to the upper right then move Date removed upward > OK
For the benefits of others looking for answers, please mark as answer suggestion if it solves your problem.
-
Date range prompt--Null default value
Hello
It is a follow-up on post Date invites default NULL
I have a similar case but using database directly request the report and have implemented a variable presentation with two date ranges. I want to leave the default value of the date white values in the dash prompt, but have the ability to enter values in the other guests and ignore the date of the application
I have 4 variables of presentation being placed in the SQL query, two of which are the date ranges (between)
I use OBIEE 10.3.1.4, is there a workaround to run the report using the other prompt values and ignoring the date values null?
Hello
Keep your 1900 filter in report itself and no default value chosen at the prompt. If this value is not visible in the dashboard and it will fly too when the user selects a value from the command prompt.
Thank you
AJ
-
All the members (but 1) are removed from the entity dimension in planning and deployed to essbase.
-What are the data deleted in essbase so?
The data can be restored by restoring the entity dimension? EPMA the entity dimension is still in tact.
It is unclear what exectly arrived, but looks like a change was made in the dimension entity planning (not EPMA) and then deployed (successfully).
In essbase, we see that the entity dimension has only one member left for the appropriate plan types, as in the planning.
If you remove members and then push that yes the essbase data is deleted, if you need back then you will need to go back to your restore process.
See you soon
John
-
Hello
To maintain the integrity of Refrential, we have included nulls for some of the columns in the database, but when I use the columns of the guests at his watch these nulls as well. For now, I got deletion of nulls SQL results. I was wondering is there all work around for the removal of null values instead of using filter conditions and writing sql for you ask?
Thank you
Phani.If do not want these nulls frontend...
You can restrict their in LTS... to the RPD content filteringgo to this particular logical dimension table where this column comes from form and then content tab.
you find where clause parameters it (called content filtering) then using button of eclipse, you can apply this filter...:Column is not null
Published by: Kishore Guggilla, October 12, 2010 11:55
-
Exclude a combined field data field empty (null)
Hello
I have a simple (I hope) question I'm stuck...
At one point in our form, we ask for the cell at home and work numbers. These are optional.
later we want to re - use the phone contact information provided earlier
the second place (call it field X in our example) where these data are using I was going to just go something like
this.rawValue = A.rawValue + rawValue. b + c. rawValue;
where A, B, C are cell phone, work fields and home earlier and that = X.
But this happen inserted fields NULL if the user leaves the initial blank (for example is they only have a cell and thus leave the House empty).
So I would test to see if the field is null, before it can be used
can anyone suggest a code that allows the following logic
x.rawValue = A.rawValue + B.rawValue + C.rawValue SO LONG AS A, B AND C all THE PHONE NUMBERS IN
otherwise if ONLY A AND B have given then x.rawValue = A.rawValue + B.rawValue
otherwise if ONLY A and C
or only has
etc.
then the correspondent only filled fields of x rawvalue-
I have experienced various syntax but can not get it quite right - someone ' can someone help or does have a sample of something similar that I can mold my needs?
Thanks in advance
var strAValue, strBValue, strCValue
Get a value
If (A.rawValue == null |) A.rawValue is"")
strAValue = "";
on the other
strAValue = A.rawValue;
Get the value B
If (B.rawValue == null |) B.rawValue is"")
strBValue = "";
on the other
strBValue = B.rawValue;
Get the value of C
If (C.rawValue == null |) C.rawValue is"")
strCValue = "";
on the other
strCValue = C.rawValue;
X.rawValue = strAValue + strBValue + strCValue;
I hope this helps...
Thank you
Srini
-
Enterprise remote data deletion
Hello everyone, I'm still new in the it field. I got a year ago, with a degree of general partners of a school local tech. I'm currently studying for my Windows 8 cert. I read an e-book and came across remote deletion of corporate data. I was talking to a colleague who is interested and wants to learn more. I'm doing some research on this subject. What I understand users can use their smartphone or laptop and connect to the network/domain to access the data. If the laptop or the phone goes missing, we can use this tool to remotely wipe the device or temporarily to make the data on the device unusable. I understand that RBDR is using Exchange ActiveSync to management along with Active Directory for authentication. Many of our customers use Office 365, so everything is done in the cloud. I have done a lot of research on Google but have not found much RBDR except that it is. Can someone help me understand this tool or point me to a good article that explains a bit more in depth about how this works.
Any help is very appreciated. I'd like to understand what this tool and how it works.
Thank you.
Brandon
Removal of remote enterprise data: Allows personal devices to connect to, access and store the business content that can be effectively removed from the device by HIM at a later date, while retaining the personal data intact.
Selective Windows wipe for the management of data from devices
http://TechNet.Microsoft.com/en-us/library/dn486874.aspx
Do a wipe on a Mobile phone remotely
http://TechNet.Microsoft.com/en-us/library/aa998614 (v = exchg.150) .aspx
I have earlier recommended that you post on TechNet Forum. These are specialists who are better able to answer all your questions about RBDR. You can also try to post questions on this site Office 365.
-
restore data deleted on partitioned drive
I accidentally deleted important data (photos and videos) on a partitioned drive (drive F), but I can't find a basket on the partitioned drive. Deleted files are not in the Recycle Bin on drive C. How I could access the trash on this drive or is there another way I can retrieve this important data? Thank you
Jerome Godin
Hello
Check with the manufacturer of cameras they have probably done this before.
Also check the Piriform Forums and those of the software that you used, if they have forums.
Recuva - free - recovers files deleted from your Windows computer, Recycle Bin,
map of the camera digital or MP3 player. And it's free!
http://www.Piriform.com/RecuvaForums - help here
http://Forum.Piriform.com/I hope this helps.
Rob Brown - Microsoft MVP<- profile="" -="" windows="" expert="" -="" consumer="" :="" bicycle="" -="" mark="" twain="" said="" it="">->
-
Trigger to insert data on the null columns
Hi all
How can I create triggers to insert data into a column null, this column is a Varchar2.
Thanks in advance.
Something like this:
create or replace the TRG_BI_MYTABLE before insert on MYTABLE for each line
Start
: new. MYCOLUMN: = nvl(:new.) MYCOLUMN, 'A value');
end;
-
Search, select and delete Pages Null?
While trying to find a way to quickly reduce the size of large PDF files that are read online, I thought I would highlight a keyword on the pages that I need and then delete pages without annotations. I decided to replace step 2 action to search and highlight words with my own script. The script I came up with, (my first) works very well on the 35-page document that I used to develop:
var pageArray =]
for (var i = 0; i < this.numPages; i ++)
{
Aannots = this.getAnnots (i);
If (Aannots is nothing)
{
pageArray.push (i);
};
pageArray.sort ();
pageArray.reverse ();
}
for (var j = 0; j < pageArray.length; j ++)
{
this.deletePages (pageArray [j], [j] pageArray)
}
but when run on a very grand, 2000 + page doc, it removes some of the pages, then crashes or finishes with:
«TypeError: invalid argument type.»
Undefined Doc.deletePages:62:Batch: Exec
= > Start parameter. » »
in the console.
If I continue to run this code in the console, it subsequently deletes all pages not annotated.
Since the arguments come from the matrix, I print and am surprised that it is not in reverse numerical order, than I expected.
Could it be the problem? or one of them?
Thanks for any help you can give... to 65, I don't know if I'll live long enough to understand this!
When you remove items from any kind of table, it is always a good idea to loop top from the end of the beginning, because you delete items inside you effectively change the size of the array and this can screw up the next steps in your loop.
Otherwise, you will need to reverse the order of the table (which your code is trying to do, but it does not work because of how works the sort function). Try this code instead:
var pageArray=[] for (var i = 0; i < this.numPages; i++) { Aannots = this.getAnnots(i); if (Aannots == null) { pageArray.push(i); }; } pageArray.reverse(); for (var j = 0; j < pageArray.length; j++) { this.deletePages(pageArray[j],pageArray[j]) }
-
Restore data deleted by mistake from the production oracle table
Forms [32 bit] Version 10.1.2.0.2 (Production)
Oracle Toolkit Version 10.1.2.0.2 (Production)
PL/SQL Version 10.1.0.4.2 (Production)
Oracle V10.1.2.0.2 - Production procedure generator
PL/SQL Editor (c) WinMain Software (www.winmain.com), v1.0 (Production)
Query Oracle 10.1.2.0.2 - Production Designer
Oracle virtual graphics system Version 10.1.2.0.2 (Production)
The GUI tools Oracle Utilities Version 10.1.2.0.2 (Production)
Oracle Multimedia Version 10.1.2.0.2 (Production)
Oracle tools integration Version 10.1.2.0.2 (Production)
Common tools Oracle area Version 10.1.2.0.2
Oracle 10.1.0.4.0 Production CORE
This morning I deleted data tables of production not having is not all correct conditions. This removed some required data.
Y at - it a command to retrieve these data? Help is appreciated. The table name is
dept_staff
"where SCHEDULE_DATE between ' 9-mar-2014' and 15-mar-2014."
I used this query
SELECT * from dept_staff
FROM TIMESTAMP
TO_TIMESTAMP ('2014-03-03 07:00 ',' YYYY-MM-DD HH)
"WHERE the SCHEDULE_DATE between ' 9-mar-2014' and 15-mar-2014."
Is this OK. Is - this show what existed in the table at 07:00 today? before deleting?
-
1. create the tenant 'INC-Cloud '.
2. Add the storage of identification number
3.I try to browse and add a user to be TENANT ADMIN, no problem
4. click on update
5. now I'm back in INC-Cloud and I can't see the user I just added what I see is "No. DATA SELECTED.
6. I tried CHome and firefox, same result
7. I added a store ID to the vshpere.local tenant and have exactly the same problem
Thank you!!!
UPDATE
I am also "NULL" (using IE) when I try to log on to the TENANT listed above "INC.-CLOUD", I know it's to see this ID in a way as if I change a letter in the PASSWORD, I got "invalid password"
Post edited by: quantum_2 Update: I can't find anything about this in catalina.out
Something funny/strange in the file vmware-identity - sts.log on the SSO Server?
Maybe you are looking for
-
OK to install grub crawler on Firefox?
Is it safe to install Grub crawler with Mozilla Firefox?
-
Got wifi problem ios 9, how to fix? Help me
WiFi problem
-
When I log into Hotmail, I always get a page of MSN news for the United Kingdom. Given that keeps the same news page Firefox 4 download - which for Saturday, March 26, 2011. When I use Internet explore and leave Hotmail I have news of the current day
-
Problem connecting Bluetooth with Windows Mobile Device Center
Hello I have and HTC Snap with WM 6.1 I want to connect to my Satellite P500 running Windows 7 to be able to move the files by using Windows Mobile Device Center. I know that this device can talk to this laptop via bluetooth, because there are some u
-
Hello everyone! Here's my problem: When I turned on my Xoom this morning I received the notification that he was ready to receive the update of the system. I clicked to start the download of the update, and then noticed that my Xoom was using 3G inst