You are here: Re: stock control, procedures « MsSQL Server « IT news, forums, messages
Re: stock control, procedures

Posted by Ed Murphy on 05/07/07 09:01

estesiquevale@gmail.com wrote:

> I have a table like this:
>
> thing, size, color, type_mov, vary
> 1, s, red, sell, 1
> 1, s, red, buy, 2
> 1, m, green, return, 10
> ....
>
> and the question is how I can see the total number of products by size
> and color having in mind that some type of movement are + and other
> are -.

This should get you on the right track:

select thing, size, color, sum(
case when type_mov in ('buy', 'return') then vary else -vary end
) as total_change
from the_table
group by thing, size, color

 

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

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