473,385 Members | 1,780 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How to use NULLS first

4
I have a table which has about 7 columns and the first row of all the collums is NULL.. when i do a select statement something like

Select * from tablename order by col0 NULLS FIRST..

It says the NULLS clause is not supported.

If i use simply

Select * from tablename order by col0 ..

By default the Null row is displayed at the last but i created it in the first row..

How to use the select statement such that i get the nulls values first as like i created..
Jun 11 '07 #1
3 6638
r035198x
13,262 8TB
I have a table which has about 7 columns and the first row of all the collums is NULL.. when i do a select statement something like

Select * from tablename order by col0 NULLS FIRST..

It says the NULLS clause is not supported.

If i use simply

Select * from tablename order by col0 ..

By default the Null row is displayed at the last but i created it in the first row..

How to use the select statement such that i get the nulls values first as like i created..
you can have the nulls at the bottom if you do order by col0 desc but that would reverse the order of your col0 values as well.
Jun 12 '07 #2
If you are happy to see a work column in the result table you can replace the null value with a literal for the purpose of ordering. e.g.:-

Select coalesce(col0,'*NULL') as col0x, tablename.*
from tablename order by col0x
Jun 28 '07 #3
I have the same type of issue. I'm looking for a way to alter the behavior of NULLS last and have NULLS first across the board without having to modify a handfull of existing queries. Apparently, DB2 Express does not suppot the "NULL FIRST" condition of an ORDER BY clause. I'd prefer not to have to do that anyway, as I would prefer to keep my queries as database-independent as possible. Some DBMS will allow the NULL weight to be specified as a database or system parameter. I've yet to find a way to do this with DB2 Express. Anybody else have any suggestions?


Rick
Jun 28 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Steve Walker | last post by:
Hi all. I've been tasked with "speeding up" a mid-sized production system. It is riddled with nulls... "IsNull" all over the procs, etc. Is it worth it to get rid of the nulls and not allow...
0
by: Rhino | last post by:
I am working with SQL Functions in DB2 for Windows/Linux/UNIX (V8.2.1) and am having a problem setting input parameters for SQL Functions to null in the Development Center. My simple function,...
3
by: Simon | last post by:
Hi all, Do you think the best way to avoid the problems of nulls in the database is just to provide default values via the db schema? Alternatively, is it better to allow nulls, seeing as the...
1
by: Angela | last post by:
Hi I am building a very simple data entry system with many forms and input textboxes. When I leave any part of the form empty (it allows nulls) it seems to touch the field in the DB and the...
12
by: Brian Henry | last post by:
first question... I have a flat file which unfortinuatly has columns seperated by nulls instead of spaces (a higher up company created it this way for us) is there anyway to do a readline with this...
1
by: buc | last post by:
I have created a byte array (1000 in size) to recv a network packet. I recv the packet, which varies in size, and need to put the packet in a string; so I can append another string after the packet...
2
by: Janick Bernet | last post by:
I just stumbled upon this olap function and wondered why the "NULLS FIRST/LAST" clause is not possible in normal order by but only using row_number() over(). Sure, I can do a SELECT *,...
5
by: John | last post by:
Hi I have a vb.net winform data app with sql server 2005 backend. The ID field in the tblClients table is an 'int' identity column that does not allow nulls. The problem is that when I try to...
6
by: Cliff72 | last post by:
I need to fill in the nulls in the batch field the value from the record immediately preceding the null one ie replace the nulls with the preceding value until I hit a record with a value in...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.