all groups > sql server (alternate) > july 2006 >
You're in the

sql server (alternate)

group:

Sorting with NULL


Sorting with NULL Sharif Islam
7/28/2006 2:53:28 PM
sql server (alternate):


I used SET
CONCAT_NULL_YIELDS_NULL OFF do ignore NULL in concatation. I have two
fields:
chapterauthor




authors

Here's my query:
SELECT ([chapterauthor] + [authors]) AS CT FROM Items ORDER BY CT


Both Authors and ChapterAuthor can be null. I am trying to figure out if
I can ignore the null value when ChapterAuthor is null.

Sample data/result:
Appadurai, Arjun #chapter author is null





Appadurai, ArjunFardon, Richard (ed.) #
(chapterauthor+authors)

I would like the output to be like this:




Appadurai, ArjunFardon, Richard (ed.) #
(chapterauthor+authors)
Appadurai, Arjun #chapter author is null


I guess I can write a stored procedure with if/else, but I was wondering
If I can do this with a simple query. Thanks.




Re: Sorting with NULL --CELKO--
7/30/2006 6:19:32 PM
[quoted text, click to view]

Why? Do you always violate ANSI/ISO standards in your code? Why not
write portable code with COALESCE()? Or with a DEFAULT and a CHECK()
constraint?"

Most bad DML comes from bad DDL.
AddThis Social Bookmark Button