ORDER BY a column with NULL values only
HelloThe order of column has all null values for the results of my query set.
Ex:
Select a, b, c from table1 where type = 'type1' and ID = "id1" order by column1
In the above query, "column1" contains nulls for 'type1 '. The order of the records in the result set is different for different ID values if the values of a, b and c are always the same.
What is happening in the 10g database.
I have also observed that the order of the records for the same query conforms in the 9i database.
(1) is the difference due to the difference in versions of database?
(2) is there a way to get the order even records independently entry ID?
(3) I cannot in the same order in 10 g DB too as the order in 9i DB?
Thank you.
Hello
Madhuri says:
HelloThe order of column has all null values for the results of my query set.
Ex:
Select a, b, c from table1 where type = 'type1' and ID = "id1" order by column1
In the above query, "column1" contains nulls for 'type1 '. The order of the records in the result set is different for different ID values if the values of a, b and c are always the same.
What is happening in the 10g database.I have also observed that the order of the records for the same query conforms in the 9i database.
If two or more rows have the same values (or NULL) for each ORDER BY expressions, then you may not be sure what order they will be. The system is free to do whatever he finds convenient. What the system identifies Dresser can vary depending on many factors, including the version, the size of the table, the conditions in the WHERE clause, there is a GROUP BY clause, or not... In all cases, it is not something that you can depend on. If you want the output in a certain order, to specify the order in the ORDER BY clause.
(1) is the difference due to the difference in versions of database?
Could be. In all versions, Oracle said that you cannot count on the order being compatible, except if the ORDER BY clause, it is consistent.
(2) is there a way to get the order even records independently entry ID?
Add more expressions at the end of the ORDER BY clause, as tie-breakers.
For example:
ORDER BY column1
, a
, b
, c
If table1 is really a table (not a view), you can add a ROWID.
In most cases, you can ORDER BY expressions that are not in the SELECT clause. So if you have a primary key, you can usually ORDER BY it, even if you don't see it.
(3) I cannot in the same order in 10 g DB too as the order in 9i DB?
Of course, ORDER BY works the same in all versions. If you have an ORDER BY clause to unambiguously, the output will be exactly the same order in any version.
Remember that the absence of ORDER BY has no effect in all versions. If you have an ORDER BY of ambiguous clause, you can not count on the coming out in a particular order in any version.
Tags: Database
Similar Questions
-
Hi all
I have a requirement where I need to get all the records, for each record in double, I need to get a single column with null or 0.
create table a1
(
Identification number,
VARCHAR2 (100), the point
part varchar2 (100));
Insert into a1
values (1, 'ABC', 'A1');
Insert into a1
values (2, 'DEF', 'A2');
TABLE A
PART ITEM ID
1 ABC A1
1 ABC A1
1 ABC A1
DEF 2 A2
DEF 2 A2
3 DEF A2
O/P
PART ITEM ID
1 ABC A1
1 ABC 0
1 ABC 0
DEF 2 A2
2 DEF 0
3 DEF 0
Thanks in advance.
Thanks for your help FrankKalush...
This one will work.
WITH got_r_num AS
(
SELECT NVL (a1.id, a1.id) as id
NVL (a1.item, a1.item) AS element
NVL (a1.part, a1.part) IN the framework
a1.id AS a_id
ROW_NUMBER () OVER (PARTITION BY a1.id
ORDER BY NULL
) AS r_num
BY the a1
)
SELECT id
element
CASE
WHEN a_id IS NOT NULL
AND r_num = 1
THEN part
ELSE ' 0'
END in the framework
OF got_r_num
;
-
Hello
I'm using Oracle 11 g. I have a table with an id of 3, node, the value column. Combination of the column id and node, that must be taken account for deletion on the registers.
Here, I need to delete lines with the NULL value in the value column. If for a combination of id and node with non-null values, then I need to delete rows with a null value for this combination.
If the combination of id, node is not null value then this records should not delete.
Below table, I need to remove the second row, for which is a value not zero VOICE CAL '10' is there, so I need to delete the row with null values. (VOICE, CAL, NULL)
Network, FL, there is no value is non-null then I should NOT delete this line.
This table is to have 100 s of this association, we can delete data in a single delete query?
Or how I can delete rows with nulls for this combination.
Tab1
VALUE OF THE NŒUD ID
VOICE CAL 10
VOICE CAL NULL
NETWORK NULL FLThank you
Hello
oradba11 wrote:
Hello
I'm using Oracle 11 g. I have a table with an id of 3, node, the value column. Combination of the column id and node, that must be taken account for deletion on the registers.
Here, I need to delete lines with the NULL value in the value column. If for a combination of id and node with non-null values, then I need to delete rows with a null value for this combination.
If the combination of id, node is not null value then this records should not delete.
Below table, I need to remove the second row, for which is a value not zero VOICE CAL '10' is there, so I need to delete the row with null values. (VOICE, CAL, NULL)
Network, FL, there is no value is non-null then I should NOT delete this line.
This table is to have 100 s of this association, we can delete data in a single delete query?
Or how I can delete rows with nulls for this combination.
Tab1
VALUE OF THE NŒUD ID
VOICE CAL 10
VOICE CAL NULL
NETWORK NULL FLThank you
You can do this in a single DELETE statement (it is not a request), using an EXISTS or IN the subquery. For example:
REMOVE table_x m
WHERE the value IS NULL
AND THERE ARE)
SELECT 0
FROM table_x s
WHERE s.id = m.id
AND s.node = m.node
AND s.value IS NOT NULL
)
;
If you would care to post CREATE TABLE and INSERT instructions for the sample data, and then I could test it.
-
I have a column with two values, separated by a space, in each line. How do I create 2 new columns with the first value in one column and the second value in another column?
Add two new columns after than the original with space separated values column.
Select cell B1 and type (or copy and paste it here) the formula:
= IF (Len (a1) > 0, LEFT (A1, FIND ("", A1) −1), ' ')
shortcut for this is:
B1 = if (Len (a1) > 0, LEFT (A1, FIND ("", A1) −1), ' ')
C1 = if (Len (a1) > 0, Member SUBSTITUTE (A1, B1 & "", ""), "")
or
the formula of the C1 could also be:
= IF (Len (a1) > 0, RIGHT (A1, LEN (A1) −FIND ("", A1)), "")
Select cells B1 and C1, copy
Select cells B1 at the end of the C column, paste
-
How to display the line empty as a line with null values
Hi all
Pls advise me if it is possible to use a single query statement to display
Empty row (i.e. not a single return line) as a line with null values.
For example,.
Select the names of names_mst whose name = "sgasfgs".
Result:
Names of
=====
< null >Hello
If you desire to join external to double, as shown below, you still get at least a line of productionSELECT nm.names FROM dual LEFT OUTER JOIN names_mst nm ON nm.name='sgasfgs';
-
update of NULL in the column with the values of the adjacent column
Examples of data
with test_data as (select 1 as one, null as two, 2 as three,5 as four, 6 as five, null as six from dual union all select 1 as one, null as two, 2 as three,5 as four, 6 as five, null as six from dual) select * from test_data;
This is one of those cases, the case may be where any value of a column can be null
or two similar columns can be null. If the column is null then I want to update the adjacent column
average value of the column, if the first column is null so I want to take the next non-null column and update, if the last column is null
so I want to take prev not zero column and to update.
In this case would be my expected output
Un Two Three Four Five Six 1 1.5 2 5 6 6 1 2 3 5 6 6 Prospects for the future the suggesion or advice.
Or, using Analytics:
SQL> with test_data (id, one, two, three, four, five, six) as ( 2 select 1, 1 , null, 2 , 5, 6, null from dual union all 3 select 2, 1 , null, 3 , 5, 6, null from dual union all 4 select 3, 1 , null, null, 5, 6, null from dual union all 5 select 4, null, null, null, 5, 6, null from dual 6 ) 7 select * 8 from ( 9 select id 10 , cell 11 , case when next_nn is not null and prev_nn is not null 12 then (next_nn + prev_nn)/2 13 else nvl(next_nn, prev_nn) 14 end val 15 from ( 16 select id 17 , cell 18 , val 19 , last_value(val) ignore nulls over(partition by id order by cell) as prev_nn 20 , first_value(val) ignore nulls over(partition by id order by cell range between current row and unbounded following) as next_nn 21 from test_data 22 unpivot include nulls (val for cell in (one as 1, two as 2, three as 3, four as 4, five as 5, six as 6) ) 23 ) 24 ) 25 pivot ( min(val) for cell in (1 as "ONE", 2 as "TWO", 3 as "THREE", 4 as "FOUR", 5 as "FIVE", 6 as "SIX") ) 26 ; ID ONE TWO THREE FOUR FIVE SIX ---------- ---------- ---------- ---------- ---------- ---------- ---------- 1 1 1,5 2 5 6 6 2 1 2 3 5 6 6 3 1 3 3 5 6 6 4 5 5 5 5 6 6
-
Throw the records with null values columns
Hi all.
Anyone know how to dispose of records containing null column values?
In the target table, I have the set Null option? with "N"... then the process sqlldr load some records. I need to load all of this without the records with null column values. by result, if the field X is null then load the file.
Kind regards.
Published by: ASzo on 05/06/2013 12:37
Published by: ASzo on 05/06/2013 12:38
Published by: ASzo on 05/06/2013 12:42load data
INFILE...
in the table...
When x! = ''
fields completed by...
(x ...) -
Calculation of the sum of a column on a XML editor RTF with NULL values
Hello
I have a problem to get the sum of a column in XML editor RTF, if one of the lines has a null value.
say, I have 4 columns and values
CASES1:
NULL, NULL, 4, NULL
Sum, I expect is: 4
CASE2:
NULL, NULL, NULL, NULL
I'm waiting for is a null
Is there a way to do this?
Thank you
AnitaTry this
AMT's column
-
Is it possible under the ORDER BY clause to not have null values climb on top
Examples:
SQL code...
ORDER BY
BL / / DESC
~*~*~*~*~*~*~*~
RESULT
bl*
(null)
8675309
--------------------------------------
ORDER BY
BL CSA
RESULT
bl*
(null)
8675309
Any thoughts?Yes, you can
select * from emp order by comm NULLS LAST ; OR select * from emp order by comm NULLS FIRST;
SS
-
Add filter slot table form to show the lines with null values
Hello
I have a tabular presentation where we need to add a filter with two values (selection list) so that if one of the columns in a table (column1) is zero, then I need to display all records where column1 is null.
I was wondering how do I put this in the Source of tabular forms where condition. This filter has only two values,
All the
NULL for the error
So when the user selects all, then all the records in the table are shown
If the user selects 'Value Null in error', while the records where Column1 is null will be shown
For example
If the user selects, thencolumn1 column2 A B 1 C 3 D
all four files will show up. Else, only the first and the second will be returned.
Thank youHi, Ryan.
Try a static LOV like this
STATIC2:;,--- All ---;--- All ---
and a Where clause, like this
where column1 is null or :p1_filter like '%%'
Jeff
-
REGEXP_SUBSTR for the list delimited by commas with null values
Hello
I have a column that stores a list of values comma-delimited. Some of these values in the list may be null. I'm having some trouble trying to extract the values using the REGEXP_SUBSTR function when null values are present. Here are two things I've tried:SELECT REGEXP_SUBSTR (val, '[^,]*', 1, 1) pos1 ,REGEXP_SUBSTR (val, '[^,]*', 1, 2) pos2 ,REGEXP_SUBSTR (val, '[^,]*', 1, 3) pos3 ,REGEXP_SUBSTR (val, '[^,]*', 1, 4) pos4 ,REGEXP_SUBSTR (val, '[^,]*', 1, 5) pos5 FROM (SELECT 'AAA,BBB,,DDD,,FFF' val FROM dual); POS P POS P P --- - --- - - AAA BBB
As you can see that neither calls work correctly. Anyone know how to change the regular expression pattern to handle null values? I tried various other models but could not get anyone to work in all cases.SELECT REGEXP_SUBSTR (val, '[^,]+', 1, 1) pos1 ,REGEXP_SUBSTR (val, '[^,]+', 1, 2) pos2 ,REGEXP_SUBSTR (val, '[^,]+', 1, 3) pos3 ,REGEXP_SUBSTR (val, '[^,]+', 1, 4) pos4 ,REGEXP_SUBSTR (val, '[^,]+', 1, 5) pos5 FROM (SELECT 'AAA,BBB,,DDD,,FFF' val FROM dual); POS POS POS POS P --- --- --- --- - AAA BBB DDD FFF
Thank you
Martin
-----
http://www.ClariFit.com
http://www.TalkApex.comHi, Martin,.
That's what you want:
SELECT RTRIM (REGEXP_SUBSTR (val, '[^,]*,', 1, 1), ',') pos1 ,RTRIM (REGEXP_SUBSTR (val, '[^,]*,', 1, 2), ',') pos2 ,RTRIM (REGEXP_SUBSTR (val, '[^,]*,', 1, 3), ',') pos3 ,RTRIM (REGEXP_SUBSTR (val, '[^,]*,', 1, 4), ',') pos4 ,RTRIM (REGEXP_SUBSTR (val || ',' , '[^,]*,', 1, 5), ',') pos5 FROM (SELECT 'AAA,BBB,,DDD,,FFF' val FROM dual);
The query above works in Oracle 10 or 11, but in Oracle 11, you can also do it with only REGEXP_SUBSTR, without using RTRIM:
SELECT REGEXP_SUBSTR (val, '([^,]*),|$', 1, 1, NULL, 1) pos1 ,REGEXP_SUBSTR (val, '([^,]*),|$', 1, 2, NULL, 1) pos2 ,REGEXP_SUBSTR (val, '([^,]*),|$', 1, 3, NULL, 1) pos3 ,REGEXP_SUBSTR (val, '([^,]*),|$', 1, 4, NULL, 1) pos4 ,REGEXP_SUBSTR (val, '([^,]*),|$', 1, 5, NULL, 1) pos5 FROM (SELECT 'AAA,BBB,,DDD,,FFF' val FROM dual);
The problem with your first request was that he was looking for sub channels of 0 or more non-virgules. There was as a substring. consisting of 3 characters starting at position 1, he returned "AAA", as expected. Then there was an another substring, the 0 characters, starting at position 4, so it returned NULL. Then, there was a substring of 3 characters starting at position 5, so he returned 'BBB '.
The problem with your 2nd request was that he was looking for 1 or more non-virgules. 'DDD' is the 3rd this substring.
Published by: Frank Kulash, on February 16, 2012 11:36
Added Oracle 11 example -
Update updated the columns with null are excluded from the DB adapter
Hi all
My fusion system interacts with DB2 using the DB adapter.
I have a script that I need to update a flag in the table after completing my bpel workflow. But by updating the value of indicator to "Processsed", there are other columns with a NULL value.
How to solve this problem. I don't want to do, the other columns should not be alerted.
Thank you
Richa
Hello
The issue has been resolved. In fact, I've updated the update statement, excluding items that couldnot be updated top link mappings. I had to create a new adapter and it worked.
Concerning
-
How to update columns with the value of other lines in the same table
Hello
I use Oracle 11.2, I'd use SQL statements to update a column based on values in other rows in the same table. Here are the details:
create table TB_test (number 4 myId, crtTs date, date of MDPU);
insert into tb_test (1, to_date ('20110101', 'YYYYMMDD'), null);
insert into tb_test (1, to_date ('20110201', 'YYYYMMDD'), null);
insert into tb_test (1, to_date ('20110301', 'YYYYMMDD'), null);
insert into tb_test (2, to_date ('20110901', 'YYYYMMDD'), null);
insert into tb_test (2, to_date ('20110902', 'YYYYMMDD'), null);
After you run the SQL code, I would like to have the following result:
1, 20110101, 20110201
1, 20110201, 20110301
1, 20110301, null
2, 20110901, 20110902
2, 20110902, null
Thanks for your suggestion.I guess you need this, otherwise please explain logic correctly:
SQL> merge into tb_test t 2 using ( 3 select rowid as rid 4 , lead(crtts) over(partition by myid order by crtts) as updts 5 from tb_test 6 ) v 7 on (t.rowid = v.rid) 8 when matched then update 9 set t.updts = v.updts 10 ; 5 rows merged. SQL> select * from tb_test order by 1,2; MYID CRTTS UPDTS ---------- --------- --------- 1 01-JAN-11 01-FEB-11 1 01-FEB-11 01-MAR-11 1 01-MAR-11 2 01-SEP-11 02-SEP-11 2 02-SEP-11
-
creating table of partition with null values
Hello
I have a table with 20 GB of data. I changed this table in the table to partition with partition of the range
the column with which I took for range (date), holding the values null
can I have a partition for null values?Hello
CREATE TABLE ICBS. KNET_STMT_EXTRACT_NEW_P
(
SRVC_TYPE VARCHAR2 (200 BYTE),
FILLER_1 VARCHAR2 (200 BYTE),
RTE_STAT VARCHAR2 (200 BYTE),
TRAN_DATE VARCHAR2 (200 BYTE),
TRAN_TIME VARCHAR2 (200 BYTE),
POST_DATE VARCHAR2 (200 BYTE),
DATE OF REC_INSERT_DT,
DATE OF PROCESSED_DATE,
KNET_RECON_RESSON VARCHAR2 (100 BYTE),
NEW_TRAN_DATE VARCHAR2 (10 BYTE),
REASON VARCHAR2 (200 BYTE)
REASON_IND NUMBER (5),
NODE_ID VARCHAR2 (8 BYTE),
PROGRAM_ID VARCHAR2 (8 BYTE),
USER_ID VARCHAR2 (8 BYTE),
TIME_STAMP DATE
)
ICBS TABLESPACE
PCTUSED 0
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE)
64K INITIALS
MINEXTENTS 1
MAXEXTENTS UNLIMITED
PCTINCREASE 0
DEFAULT USER_TABLES
)
LOGGING
PARTITION BY RANGE (REC_INSERT_DT)
(KNET_STMT_EXTRACT_NEW_P_DEC11 PARTITION VALUES LESS THAN (TO_DATE (' 2012-01-01 00:00:00 ',' SYYYY-MM-DD HH24:MI:SS ',' NLS_CALENDAR = GREGORIAN '))
LOGGING
NOCOMPRESS
ICBS TABLESPACE
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE)
INITIAL 1 M
MINEXTENTS 1
MAXEXTENTS UNLIMITED
DEFAULT USER_TABLES
),
KNET_STMT_EXTRACT_NEW_P_JAN12 PARTITION VALUES LESS THAN (TO_DATE (' 2012-02-01 00:00:00 ',' SYYYY-MM-DD HH24:MI:SS ',' NLS_CALENDAR = GREGORIAN '))
LOGGING
NOCOMPRESS
ICBS TABLESPACE
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE)
INITIAL 1 M
MINEXTENTS 1
MAXEXTENTS UNLIMITED
DEFAULT USER_TABLES
),
PARTITION KNET_STMT_EXTRACT_NEW_P_MVAL VALUES LESS THAN (MAXVALUE)
LOGGING
NOCOMPRESS
TABLESPACE TBL_MAXVALUE
PCTFREE 10
INITRANS 1
MAXTRANS 255
STORAGE)
INITIAL 1 M
MINEXTENTS 1
MAXEXTENTS UNLIMITED
DEFAULT USER_TABLES
)
NOCOMPRESS
NOCACHE
NOPARALLEL
MONITORING
ALLOW THE MOVEMENT OF THE LINE;Published by: hitgon on April 30, 2012 10:56
Published by: hitgon on April 30, 2012 10:58
Published by: hitgon on April 30, 2012 10:59
-
Value of the link column remove null values
Hello
I use 4.1.1 and I have a column in a classic report that I have configured to post a link to another page in the application. I use one of the IMGS 'edit' and I put the report to show significant like but when I run my page and the value is null, I get always a hyphen and a link (for example. ("' - that is a link) which redirects me to another page. I know a fast method of sale would be to hardcode the html code in the sql code and I know that you should really put an html tag that is similar between your sql. With this in mind are other suggestions of display and img/a for null values.
Thank you very much
AlistairYou can try css:
#r_contacts_rowview td [headers = "OFFICE_EMAIL"] a [href = "mailto:-"] {}
display: none;
}He finds the elements of anchoring with mailto value '-' (my null values) in my office_email column. r_contacts_rowview is a static id for a region.
Display: none to hide items. This works rather graceful.
Note that this works in IE7/8 your page should be a doctype ( )If you don't want a doctype or whatever it is, you can also try jquery of course
function remove_hyphen_links() {}
$("td_[en-tetes_=_'office_email']_{a").each (function ()})
{if ($(this).)} (Text()=='-')}
$(this) .remove ();
};
});
};If I run this onload of my page, I can see hyphens, shortly before they disappear, I don't like too much. Of course, you must bind it to the "apexafterrefresh" - event in your area, as well as the links are also deleted after a partial page refresh (paging).
Maybe you are looking for
-
I have Firefox 34, the app I want 2.0 needs? Apparently. Anyone have a link where I can get an older version?
-
Photosmart HP5520: 5520 HP Photosmart Memory Card Error
My Photosmart HP5520 will print from my IPhone and IPad wireless, however, on the touch screen memory card error appears saying "memory card error. Please remove the memory card. There is no memory card in the machine and I tried to unplug and discon
-
Window could not check the update
I bought a new laptop Toshiba Satellite A500/02J and install Windows 7, 64 bit.The problem is that when it's time set to automatic update of Windows 7, the message "window could not check the updated" comes top-code 8024402F - "window meeting unkown
-
Hi im using labview 8.0... I have a listbox that lists all text files in the folder... and I was able to do this nor the spirit. now my problem is that say I double click on one of the text file... I want the text file to be opened. How is it?
-
BEX with Adobe Acrobat error on Vista 32-bit operating system
I am running Vista Home Premium (32 bit) and get a Windows error message when I try to get a PDF with a password Adobe Acrobat 8.1. Reads the error message Windows: "Adobe Acrobat has stopped working. (The problem event name is BEX). And when I cl