•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the MS SQL section within the Web Development category of DaniWeb, a massive community of 391,609 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,620 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MS SQL advertiser:
Views: 636 | Replies: 3
![]() |
•
•
Join Date: May 2008
Posts: 2
Reputation:
Rep Power: 0
Solved Threads: 0
Good day all! Need assistance with the following:
I a table that houses information and want to create calculations based on the info.
I have created a view to perform one of the calcs.
Now I want to sum columns that will put info into another field that I can than perform another function. Unfortunately I keep getting aggregate errors that I need to add field in group by or select statement. I can do one, but not others. After I do one I then need to take that field and perform another calculation.
Example
SUM (Column A) AS TotalColumnA
SUM (Column B) AS TotalColumnB
Then I need to divide Column A by Column B to get to AS Column C
etc....
Since this is a vew can it be done? To further complicate this I need to be able to choose a "between date" end user fills in the begin date and end date.
YIKES!!! I have manual and have been trying to figure out, but I am brain dead trying many different things.
Your expertise would be very appreicated on how I should set this up in MS SQL. If you need a copy of what I am doing... happy to send along.
Thank you!!!!!!!!!!!!!!!!
I a table that houses information and want to create calculations based on the info.
I have created a view to perform one of the calcs.
Now I want to sum columns that will put info into another field that I can than perform another function. Unfortunately I keep getting aggregate errors that I need to add field in group by or select statement. I can do one, but not others. After I do one I then need to take that field and perform another calculation.
Example
SUM (Column A) AS TotalColumnA
SUM (Column B) AS TotalColumnB
Then I need to divide Column A by Column B to get to AS Column C
etc....
Since this is a vew can it be done? To further complicate this I need to be able to choose a "between date" end user fills in the begin date and end date.
YIKES!!! I have manual and have been trying to figure out, but I am brain dead trying many different things.
Your expertise would be very appreicated on how I should set this up in MS SQL. If you need a copy of what I am doing... happy to send along.
Thank you!!!!!!!!!!!!!!!!
•
•
Join Date: Apr 2008
Posts: 295
Reputation:
Rep Power: 1
Solved Threads: 41
hi,
this could be a solution:
If you want to select further columns, for example ColumnX together with results from aggregate functions, you need group by clause:
Maybe you post your complete SQL select statement, also view definition, possibly I might then be able to give better advice.
krs,
tesu
this could be a solution:
sql Syntax (Toggle Plain Text)
SELECT SUM (COLUMN A) AS TotalColumnA, SUM (COLUMN B) AS TotalColumnB, TotalColumnA / TotalColumnB AS TotalColumnC FROM yourTable;
If you want to select further columns, for example ColumnX together with results from aggregate functions, you need group by clause:
sql Syntax (Toggle Plain Text)
SELECT ColumnX, SUM (ColumnA) AS TotalColumnA, SUM (ColumnB) AS TotalColumnB, TotalColumnA / TotalColumnB AS TotalColumnC FROM yourTable GROUP BY ColumnX;
Maybe you post your complete SQL select statement, also view definition, possibly I might then be able to give better advice.
krs,
tesu
•
•
Join Date: May 2008
Posts: 2
Reputation:
Rep Power: 0
Solved Threads: 0
Thank you so much for quick response!!! I tried your formula and I'm sure it'scorrect, but my dilemma is a bit more complex. I'm not sure if this has something to do with it, but I have created a view to get totals for other columns,and am then creating this other view to pull them together and run totals and new formulas on those totals. I have attached a screen print to show you what I am doing. Since I am fairly new to all of this I hope I'm not in over my head and you can give me some help.
Everything I am trying to do is in a spreadsheet which is very cumbersome and not productive, hence why I am creating a database. If you have any questions you are welcome to email me at lfarruggia@athleticausa.com.
I would be very appreciative for your help.
Again my sincere thanks to put me on the right track! I have a sql book, but it's just not detailed enough to help me or I'm just too plain stupid to understand it! smile...
Everything I am trying to do is in a spreadsheet which is very cumbersome and not productive, hence why I am creating a database. If you have any questions you are welcome to email me at lfarruggia@athleticausa.com.
I would be very appreciative for your help.
Again my sincere thanks to put me on the right track! I have a sql book, but it's just not detailed enough to help me or I'm just too plain stupid to understand it! smile...
•
•
Join Date: Apr 2008
Posts: 295
Reputation:
Rep Power: 1
Solved Threads: 41
Hi again,
well, I have got some problems understanding your screen shots. Wouldn't it be easier you post your sql code for tables and view creations? I know, if select statements are getting more and more complex, creating views or stored procedure is obviously an appropriate vehicle to get some provisional results where further results might be drawn from. Do you ever thought of using WITH clause?
Maybe I will be able to give you further advice when I would have seen the create-view and create-tables code.
krs,
tesu
well, I have got some problems understanding your screen shots. Wouldn't it be easier you post your sql code for tables and view creations? I know, if select statements are getting more and more complex, creating views or stored procedure is obviously an appropriate vehicle to get some provisional results where further results might be drawn from. Do you ever thought of using WITH clause?
Maybe I will be able to give you further advice when I would have seen the create-view and create-tables code.
krs,
tesu
Last edited by tesuji : Jun 30th, 2008 at 5:56 pm.
Information is moving—you know, nightly news is one way, of course, but it's also moving through the blogosphere and through the Internets. I promise you I will listen to what has been said here, even though I wasn't here. Ann and I will carry out this equivocal message to the world. I'm the master of low expectations.
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb MS SQL Marketplace
Similar Threads
- AMD Vs Pentium (Motherboards, CPUs and RAM)
- Best Viewed Sreen Resolution (Site Layout and Usability)
- Smoking (Geeks' Lounge)
- AdSense alternatives (Advertising Sales Strategies)
- SOS Im Dyingg :( (Visual Basic 4 / 5 / 6)
- Creating an array/collection that holds variables (Visual Basic 4 / 5 / 6)
Other Threads in the MS SQL Forum
- Previous Thread: Mirror DB - Does it update schema changes too?
- Next Thread: Max value in a decimal field


Linear Mode