You are here: Re: How to? « MsSQL Server « IT news, forums, messages
Re: How to?

Posted by M A Srinivas on 06/05/07 12:23

On Jun 5, 4:02 pm, Mirnes <leme...@yahoo.com> wrote:
> I have table with following structure:
>
> Cust Amount Type
> 1 150.00 1
> 1 100.00 2
>
> I would like to get query result:
>
> Cust Type1 Type2
> 1 150.00 0.00
> 1 0.00 100.00
>
> How to do this with query?

create table #customer( cust int,amount numeric(10,2), type int)
insert into #customer values (1,150.00,1)
insert into #customer values (1,100.00,2)

select cust,
case when type = 1 then amount else 0.00 end as type1 ,
case when type = 2 then amount else 0.00 end as type2
from #customer

drop table #customer

 

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

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