473,398 Members | 2,380 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,398 software developers and data experts.

Some SQL trouble

Hello all.
I'm creating a view, and part of it.. one of the fields, i sum lets say
hours + line hours As TotalHours, itll find the 3 records, sum them,
and give me the correct amount of hours.. but I also have another field
that is totalhours / product made .. I need this to also show in the
view, but i first have to sum the total hours field. I tried doing
(SELECT Sum(hours+linehours) from table) / productmade but it gives me
the error about using an aggregate function in a group by or sum list?
Anyways, I'm not too great in SQL so if anyone has any ideas, id
greatly appreciate it. I can paste the code if it will help at all, but
its rather lengthy.

TIA

Nov 13 '05 #1
2 1083
I assume productmade is a number. How do you derive the productmade
number? Does it come from the same table as hours, linehours? How does
productmade relate to hours, linehours?

Rich

*** Sent via Developersdex http://www.developersdex.com ***
Nov 13 '05 #2
what is your initial query GROUP ed BY ?
ie SELECT SUM(hours + lineHours) as totalHours FROM table GROUP BY
something

you need the same GROUP BY in
(SELECT Sum(hours+linehours) from table group by something) /
productmade

the SUM function is an aggregate function (like COUNT, FIRST, MIN, MAX,
etc) which needs a GROUP BY clause

you can also have
SELECT SUM(hours + lineHours) as totalHours
SUM(hours + lineHours) / productMade as foobar
FROM table
GROUP BY something

Nov 13 '05 #3

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

Similar topics

3
by: fdsl ysnh | last post by:
--- python-list-request@python.orgдµÀ: > Send Python-list mailing list submissions to > python-list@python.org > > To subscribe or unsubscribe via the World Wide Web, > visit >...
193
by: Michael B. | last post by:
I was just thinking about this, specifically wondering if there's any features that the C specification currently lacks, and which may be included in some future standardization. Of course, I...
0
by: mike | last post by:
Recently I posted a message about deploying an application over a network. I had the .net framework installed on the pcs, the local intranet set to full trust, and I had copied the bin directory to...
7
by: P Pulkkinen | last post by:
This all below is my opinion, not any official post though... ====================================== 1) Have a debugging/error handling system. It is not so difficult to make, I have made one...
7
by: =?Utf-8?B?SnVzdGlu?= | last post by:
Hello Everyone: I am having the most bizarre problem with my asp.net web app...this is my first web app in asp.net and I inherited it from a programmer who quit...so, I am not completely...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.