473,396 Members | 1,938 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

SQL script - sum total issue

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.pr oject_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
Sep 9 '05 #1
2 2354
Jeffrey S via SQLMonster.com (fo***@SQLMonster.com) writes:
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.


It is unclear to me what you want. If all you want is the sum per
project and no information per component and cost_element, then
you can say:

select a.project_id, SUM(a.project_amt_1) as 'July',
SUM(a.project_amt_2) as 'August'
...
from component_monetary_balance as a, project as b, component as c
...
and project_ytd_amt <> 0
GROUP BY a.project_id

If this does not answer you question, could you please clarify with
an example?
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp

Sep 9 '05 #2
Lightbulb...thanks for the help...toggling between SQL and Cognos I forgot
the most obvious...

Erland Sommarskog wrote:
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.


It is unclear to me what you want. If all you want is the sum per
project and no information per component and cost_element, then
you can say:

select a.project_id, SUM(a.project_amt_1) as 'July',
SUM(a.project_amt_2) as 'August'
...
from component_monetary_balance as a, project as b, component as c
...
and project_ytd_amt <> 0
GROUP BY a.project_id

If this does not answer you question, could you please clarify with
an example?

--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp

--
Message posted via http://www.sqlmonster.com
Sep 9 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Yellowbird | last post by:
Hi all, I'm new to JavaScript, but am pretty sure what I want to accomplish is not that difficult. I just need an example or suggestion to help clarify it for me - I haven't had much time to...
6
by: R. Stormo | last post by:
I have a problem showing output that is comming from a script. If I make a script running at commandline it do work and everything are showing. But when I try to execute it from within my proggy...
3
by: Gord | last post by:
http://eastontario.com/promo/tableCellMultiplier.htm For a rectangular/square n column, m row table, this script formats so that all cells hold the same contents. Check out the source and vary...
2
by: Jon | last post by:
I have a datagrid with a total row on the bottom. What is the best method to "instantly" update the total row when the value of any row changes. I am running into problems when I use the column...
1
by: webguy262 | last post by:
I'm trying to modify this script... <script language="JavaScript" type="text/javascript"> <!-- /* This script is Copyright (c) Paul McFedries and Logophilia Limited...
0
by: phil469 | last post by:
I'm having an issue when trying to read a file in a user's homedir from a cgi script. I have a virtual host section in my httpd.conf file which I'll include. The cgi script is a very basic script...
4
by: microtribe | last post by:
Hi, I have a Javascript total calculation function within a php form that uses onBlur to show the client a running total of the dollar amount of items added:...
4
by: Yonih | last post by:
So I am trying to get this Calculator to work. It needs to take in a vaule, and select a shipping Everythin works great except the shipping part. I need it to take the shipping value and add it to...
1
by: Piotrekk | last post by:
Hi My application is uploading the file to the ASP script. I am dealing with situation where ASP script is not interested in receiving a file. I simulate this by returning from ASP script: ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.