You are here: Re: Query: union on self « MsSQL Server « IT news, forums, messages
Re: Query: union on self

Posted by Thomas R. Hummel on 07/11/06 13:47

Alexander Kuznetsov wrote:
> You can try something like this:
>
> SELECT qi_id,
> case
> when qi_injury = 1 then 'Injury'
> when qi_environmental = 1 then 'environmental'
> when qi_Equipment damage = 1 then 'Equipment damage'
> when qi_Vehicle = 1 then 'Vehicle'
> end
> AS type
> FROM qt_ins
> WHERE (qi_injury = 1) or (qi_environmental = 1 ) or
> (qi_equipment_damage = 1)
> or (qi_vehicle = 1)
>
> But it would be interesting to see why is your original query slow. Any
> additional infotrmation?

I just posted that this was a good solution in another post, but now it
occurs to me that it will not return the same resultset as the original
poster's solution. The query above will return only one row per qi_id,
but the original solution could return up to four for each qi_id.

-Tom.

 

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

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