You are here: Re: How to find first not null value in column « MsSQL Server « IT news, forums, messages
Re: How to find first not null value in column

Posted by Tony Rogerson on 01/30/06 12:09

>> celko, you might read a book on fundamental human communications. You
>> have missed the most important concepts.

Missed the 'most important' concepts, I think celko has missed the 'very
basic' concepts.

Don't let the guy get to you, he doesn't want to let go of 80's programming
models; but more importantly he doesn't want the industry to move on in case
we stop (or start) using the standard that the committee he belonged to
worked on.

He only spouts anything meaningful when he talks about logical models, as
soon as he moves out of that area he shows us just how out of his depth he
really is.

I keep saying to him, go get a job as a junior programmer - i think it would
help him a) communicate better and b) better understand the problems and
architectures of todays environments.

--
Tony Rogerson
SQL Server MVP
http://sqlserverfaq.com - free video tutorials


"Doug" <drmiller100@hotmail.com> wrote in message
news:1138582937.168569.155440@g14g2000cwa.googlegroups.com...
> celko writes:
>
>>ordering in an RDBMS, so "first", "next" and "last" are totally
> meaningless.
>
> Really? To me, first, next, and last do have meanings in an RDBMS,
> assuming you have an order.
>
>> If you want an ordering, then you need to havs a column
> that defines that ordering.
>
> Well, you could use a set of columns, function, or a join into another
> table to use a column from another table.
>
>>You must use an ORDER BY clause on a
> cursor.
>
> Really? I didn't see that anywhere. I've used cursors all the time
> without an order by function.
> my bad.
>
>>Next, you are talking about SQL as if you were in a file system, where
> you read one record at a time and have explicit control flow via
> procedural statements. That is also totally wrong; SQL is a
> declarative, compiled language.
>
> Hmmmmm. You can read one record at a time and have explicit control
> flow via procedural statements. That IS included in the system. Most of
> us consider the concept of "SQL" to include a paradigm for a relational
> database. What does this mean? In my paradigm, you get to use tables.
> In your's, you just get to write language, compile it, but never run
> it.
>
>
>>SELECT foo_key
> FROM Foobar
> WHERE klugger IS NULL
> AND foo_key
> = (SELECT MIN(foo_key) FROM Foobar);
>
>
>>(if there is a not null value then show me it and stop searching, the
> table is quite big)?
>
> Actually, the above code REQUIRES a complete scan of the table. It
> really is pretty bad code. The engine must locate and identify ALL
> foo_key's, and figure out which one is lowest with a null.
>
>>Show you the NULL value that does not exist? That makes no sense.
> Neither does "stop searching", since SQL is a set-oriented language.
> You get the entire result set back; it can be empty or it can have any
> number of rows.
>
> Actually, it turns out a set CAN contain one row. You can actually even
> REQUIRE that set to contain one row!!!!!
>
>>You need to read a book on RDBMS basics. You have missed the most
> important concepts.
>
> celko, you might read a book on fundamental human communications. You
> have missed the most important concepts.
>
>> If there is no NULL in klugger, then yuou will get an empty set back.
>
> Well, you could write code to tell the engine to return exactly one row
> back, whether it is null or not.
>
> select top 1 fieldname from filename where fieldname is null
>
> returns the "first" null if there is one, and an empty set if not.
>
> Perhaps though I am missing your point celko. If so, could you be more
> precise? SQL really lends itself to precise examples, and broad inexact
> generalities often confuse the issues.
> Thanks, and have a good day!
>

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация