You are here: Re: help with Select statement « MsSQL Server « IT news, forums, messages
Re: help with Select statement

Posted by SQL Menace on 09/20/06 13:08

select sifrob,katbroj,sum(kol) as kol
from Query_Result
group by sifrob,katbroj


Denis the SQL Menace
http://sqlservercode.blogspot.com/


Zvonko wrote:
> Hi!
>
> This is my table:
>
> CREATE TABLE [Query_Result] (
> sifrob VARCHAR(13),
> katbroj VARCHAR(15),
> kol FLOAT
> )
>
>
> This is some values:
>
> INSERT INTO [Query_Result] ([sifrob], [katbroj], [kol])
> VALUES
> ('49501879', 'G-46052', 1)
> INSERT INTO [Query_Result] ([sifrob], [katbroj], [kol])
> VALUES
> ('49501879', 'G-46052', 3)
> INSERT INTO [Query_Result] ([sifrob], [katbroj], [kol])
> VALUES
> ('49501910', 'G-46935', 1)
> INSERT INTO [Query_Result] ([sifrob], [katbroj], [kol])
> VALUES
> ('49508122', 'G-46944', 1)
> INSERT INTO [Query_Result] ([sifrob], [katbroj], [kol])
> VALUES
> ('49508698', 'G-50314', 1)
> INSERT INTO [Query_Result] ([sifrob], [katbroj], [kol])
> VALUES
> ('49502695', 'G-51201', 1)
>
> As you can see some vaules are duplicated and only the 'kol' is
> different. I would like to write a SELECT statements that will get all the
> values from table, but on the duplicated ones that I get it once and the
> 'kol' column is sum of the two 'kol' values ( so if we have 499501879 the
> 'kol must be 4.
>
> Please help.
>
> Best regards,
> Zvonko

 

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

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