You are here: SQL script - sum total issue « MsSQL Server « IT news, forums, messages
SQL script - sum total issue

Posted by Jeffrey S via SQLMonster.com on 09/09/05 23:49

I have this script...I would like to group the total of project_amt_1 (July)
by the project_id and the same for the 11 months and the total.



select a.project_id,a.component_id,a.cost_element_id,a.project_amt_1 as
'July',
a.project_amt_2 as 'August', a.project_amt_3 as 'September',a.project_amt_4
as 'October',
a.project_amt_5 as 'November',a.project_amt_6 as 'December', a.project_amt_7
as 'January',
a.project_amt_8 as 'February', a.project_amt_9 as 'March', a.project_amt_10
as 'April',
a.project_amt_11 as 'May', a.project_amt_12 as 'June', a.project_ytd_amt as
'2006 Total'
from component_monetary_balance as a, project as b, component as c
where a.project_id = b.project_id
and b.project_id = c.project_id
and a.project_id = c.project_id
and a.component_id = c.component_id
and a.amt_class_type = 'BOARDBUD'
and a.fiscal_year = '2006'
and a.curr_type = 'P'
and a.project_id between '01000' and '09999'
and not a.project_id in ('01067','01069','01070','01071','01072','01073',
'01074','01075','01076','01300')
and not a.component_id between '8000' and '8999'
and (not a.cost_element_id like '7639%'
or not a.cost_element_id like '8032%'
or not a.cost_element_id like '8887%'
or not a.cost_element_id like '8888%'
or not a.cost_element_id like '9685%'
or not a.cost_element_id like '9683%'
or not a.cost_element_id like '9681%'
or not a.cost_element_id like '9950%'
or not a.cost_element_id like '9955%'
or not a.cost_element_id like '8499%')
and b.project_status in ('T','A')
and c.component_status in ('T','A')
and project_ytd_amt <> 0

Thanks


--
Message posted via http://www.sqlmonster.com

 

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

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