You are here: Re: Help with Query « MsSQL Server « IT news, forums, messages
Re: Help with Query

Posted by David Portas on 10/13/05 14:27

Why did you return an "F" for one row and NULL for the others? I'm
guessing that you only want to return a value in the second column
where that value is the same for every instance of the value in the
first column. I'm also guessing that both columns are not nullable in
your table (because you didn't specify any other columns that could be
a key). If that's correct, try this:

SELECT col1,
CASE WHEN MIN(col2)=MAX(col2) THEN MIN(col2) END AS col2
FROM your_table
GROUP BY col1;

(untested)

--
David Portas
SQL Server MVP
--

 

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

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