473,804 Members | 3,049 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

calculation of subqueries HELP

1 New Member
I am trying to divide 2 subqueries. there is a comment in the query pointing out what I have unsuccessfuly tried. Can anyone lead me in the right direction please.


SELECT TOP 100 PERCENT dbo.tCourseDesc riptions.Course Name, dbo.nrcAssignme nts.AssignmentT itle, dbo.nrcAssignme nts.AssignmentD ueDate,
dbo.nrcStandard .StandardAbbrev iation, dbo.nrcStandard .StandardDescri ption, dbo.nrcStandard .StateStandardI D, dbo.nrcStandard .StandardName,d bo.nrcAssignmen ts.SKAssignment ID,
(SELECT AVG(FinalGradeT otal) FROM dbo.nrcAssignme ntGrades WHERE FKASsignmentID = dbo.nrcAssignme nts.SKAssignmen tID AND Omitted <> '1') As MaxPoints,
(SELECT ROUND(AVG(Grade PointValue),0) FROM dbo.nrcAssignme ntGrades WHERE FKASsignmentID = dbo.nrcAssignme nts.SKAssignmen tID AND Omitted <> '1')As ClassAvg,
(SELECT SUM(FinalGradeT otal) FROM dbo.nrcAssignme ntGrades WHERE FKASsignmentID = dbo.nrcAssignme nts.SKAssignmen tID AND Omitted <> '1') As MaxTotal,
(SELECT SUM(GradePointV alue) FROM dbo.nrcAssignme ntGrades WHERE FKASsignmentID = dbo.nrcAssignme nts.SKAssignmen tID AND Omitted <> '1')As GPSum


-- here are the subqueries I am trying to divide.
-- I am trying to get a TRUE class average
---------------------------------------------------
,CASE WHEN 'ClassAvg' <> 0.0 THEN
((SELECT SUM(FinalGradeT otal) FROM dbo.nrcAssignme ntGrades WHERE FKASsignmentID = dbo.nrcAssignme nts.SKAssignmen tID AND Omitted <> '1')/
(SELECT SUM(GradePointV alue) FROM dbo.nrcAssignme ntGrades WHERE FKASsignmentID = dbo.nrcAssignme nts.SKAssignmen tID AND Omitted <> '1')) ELSE 0 END As MyAvg
------------------------------------------------------




FROM dbo.tStudentEnr oll INNER JOIN
dbo.tSchedule ON dbo.tStudentEnr oll.FKClassID = dbo.tSchedule.S KClassID INNER JOIN
dbo.tCourseDesc riptions ON dbo.tSchedule.F KCourseID = dbo.tCourseDesc riptions.SKCour seID INNER JOIN
dbo.nrcxAssignm entSkills ON dbo.tStudentEnr oll.FKClassID = dbo.nrcxAssignm entSkills.FKCla ssID INNER JOIN
dbo.nrcAssignme nts ON dbo.nrcxAssignm entSkills.FKAss ignmentID = dbo.nrcAssignme nts.SKAssignmen tID INNER JOIN
dbo.nrcStandard ON dbo.nrcxAssignm entSkills.FKSta ndardID = dbo.nrcStandard .SKStandardID
GROUP BY dbo.tStudentEnr oll.FKClassID, dbo.tCourseDesc riptions.Course Name, dbo.tCourseDesc riptions.Academ icYear,
dbo.nrcxAssignm entSkills.FKSta ndardID, dbo.nrcAssignme nts.AssignmentT itle, dbo.nrcAssignme nts.AssignmentD ueDate,
dbo.nrcStandard .StandardAbbrev iation, dbo.nrcStandard .StandardDescri ption, dbo.nrcStandard .StateStandardI D,
dbo.nrcStandard .StandardName,d bo.nrcAssignmen ts.SKAssignment ID
HAVING (dbo.tStudentEn roll.FKClassID = 11204)
ORDER BY AssignmentDueDa te DESC
Dec 8 '06 #1
0 1056

Sign in to post your reply or Sign up for a free account.

Similar topics

6
2063
by: Daniel Elliott | last post by:
Hello, I was wondering if anyone would be able to help me with a problem I'm having. I'm trying to use the following query: SELECT Distinct c.site_id FROM campsite c WHERE c.site_id NOT IN (SELECT cs.site_id FROM campsite_status cs WHERE c.site_id = cs.site_id
5
2429
by: Nick | last post by:
Im moving a development app (MySQL 5.0) to a different server which runs MySQL 4.0.20-standard. I am getting errors on queries that have subqueries such as... SELECT id FROM table1 WHERE id IN ( SELECT id FROM table1 )
6
5301
by: jimfortune | last post by:
In: http://groups.google.com/group/comp.databases.ms-access/msg/60d7faa790c65db1 james.ea...@gmail.com said: :Ok, I've answered the first half of my own question. From a MSDN :article, I can now use the following to reference the last primary :key's values: :
3
1380
by: Marina | last post by:
I have a querie that needs to use multiple calculations (...I think...) Fields: TransID TransDate TransDescipt ClientID HoursBilled BillingRate
2
2672
by: psuaudi | last post by:
I have a main query that I would like to call two different subqueries. In MS Access, I usually just save the two subqueries as separate queries which are then called by a third separate and main query. However, I'd like to put them all into one SQL command. Is this possible? Here are the queries: -This query calls the other two queries below- SELECT ., ., Format(((.Date)-(.Date)),"Fixed") AS , .Type FROM INNER JOIN ON (. = .) AND...
3
1617
by: ApexData | last post by:
Hello My MainForm manages Employee records. I have created another form that manages employee promotions. On the MainForm a button launches the PromotionForm and lists the promotions for the employee shown on the MainForm. The buttons clickevent looks like this: DoCmd.OpenForm stDocName, , , "EMPID = " & Me.txtEMPID The results are FILTERED. The Form is Continuous. Fields are: (EmpID) (Rank) (PromoDate) and UnboundTxtBox:
1
2153
by: Bob | last post by:
Hi all, I want to incorporate several types of different rankings to a Make Table Query I have then use the rank for calculations. I want to calculate rankings based on how much each client has in a portfolio, so lets say there are 4 portfolios, so each client would have 4 rankings, dependant upon how much they had in each portfolio compared to their peers. I then want to use each of those rankings to run some calculations. I want all...
4
2958
by: muzu1232004 | last post by:
Can anyone explain me when we use correlated subqueries rather than nested subqueries. Do all the correlated subqueries can be written in nested subqueries form as well ? What are the major conditions that apply whenever we write a correlated subquery and why we go for it ? Please let me know about this as i am not clear which to use when.
0
5710
debasisdas
by: debasisdas | last post by:
Using Subqueries ================== The sub query is often referred to as a nested SELECT, Sub - SELECT, or inner SELECT statement. The sub query executes once before the main query. The result of the sub query is used by the main query (outer Query). You can place the sub query in a number of SQL clauses. WHERE clause
0
9572
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10562
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10303
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10070
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9132
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5508
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4282
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3803
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2978
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.