473,382 Members | 1,423 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,382 software developers and data experts.

calculation of subqueries HELP

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.tCourseDescriptions.CourseName, dbo.nrcAssignments.AssignmentTitle, dbo.nrcAssignments.AssignmentDueDate,
dbo.nrcStandard.StandardAbbreviation, dbo.nrcStandard.StandardDescription, dbo.nrcStandard.StateStandardID, dbo.nrcStandard.StandardName,dbo.nrcAssignments.SK AssignmentID,
(SELECT AVG(FinalGradeTotal) FROM dbo.nrcAssignmentGrades WHERE FKASsignmentID = dbo.nrcAssignments.SKAssignmentID AND Omitted <> '1') As MaxPoints,
(SELECT ROUND(AVG(GradePointValue),0) FROM dbo.nrcAssignmentGrades WHERE FKASsignmentID = dbo.nrcAssignments.SKAssignmentID AND Omitted <> '1')As ClassAvg,
(SELECT SUM(FinalGradeTotal) FROM dbo.nrcAssignmentGrades WHERE FKASsignmentID = dbo.nrcAssignments.SKAssignmentID AND Omitted <> '1') As MaxTotal,
(SELECT SUM(GradePointValue) FROM dbo.nrcAssignmentGrades WHERE FKASsignmentID = dbo.nrcAssignments.SKAssignmentID 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(FinalGradeTotal) FROM dbo.nrcAssignmentGrades WHERE FKASsignmentID = dbo.nrcAssignments.SKAssignmentID AND Omitted <> '1')/
(SELECT SUM(GradePointValue) FROM dbo.nrcAssignmentGrades WHERE FKASsignmentID = dbo.nrcAssignments.SKAssignmentID AND Omitted <> '1')) ELSE 0 END As MyAvg
------------------------------------------------------




FROM dbo.tStudentEnroll INNER JOIN
dbo.tSchedule ON dbo.tStudentEnroll.FKClassID = dbo.tSchedule.SKClassID INNER JOIN
dbo.tCourseDescriptions ON dbo.tSchedule.FKCourseID = dbo.tCourseDescriptions.SKCourseID INNER JOIN
dbo.nrcxAssignmentSkills ON dbo.tStudentEnroll.FKClassID = dbo.nrcxAssignmentSkills.FKClassID INNER JOIN
dbo.nrcAssignments ON dbo.nrcxAssignmentSkills.FKAssignmentID = dbo.nrcAssignments.SKAssignmentID INNER JOIN
dbo.nrcStandard ON dbo.nrcxAssignmentSkills.FKStandardID = dbo.nrcStandard.SKStandardID
GROUP BY dbo.tStudentEnroll.FKClassID, dbo.tCourseDescriptions.CourseName, dbo.tCourseDescriptions.AcademicYear,
dbo.nrcxAssignmentSkills.FKStandardID, dbo.nrcAssignments.AssignmentTitle, dbo.nrcAssignments.AssignmentDueDate,
dbo.nrcStandard.StandardAbbreviation, dbo.nrcStandard.StandardDescription, dbo.nrcStandard.StateStandardID,
dbo.nrcStandard.StandardName,dbo.nrcAssignments.SK AssignmentID
HAVING (dbo.tStudentEnroll.FKClassID = 11204)
ORDER BY AssignmentDueDate DESC
Dec 8 '06 #1
0 1040

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

Similar topics

6
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...
5
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...
6
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...
3
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
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...
3
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...
1
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...
4
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...
0
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...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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?
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...

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.