hi all,
I'm having a hard time producing the correct sql statement for my tables.
below is my sql statement but i'm getting incorrect result. This particular query returns the sum of all the value of a particular field and it seems that it is ignoring the parameter which is entirely wrong.
Hope somebody can help me...thank you in advance. - SELECT RTRIM (tbl_Students.Id_No) AS IdNo, RTRIM(LastName) + ', ' + RTRIM(FirstName) + ' ' + LEFT(MiddleName,1) AS Names,
-
RTRIM(tbl_Courses.Abbreviation) + '/' + RTRIM(tbl_EnrollStatus.YearLevel) + '/' + RTRIM(tbl_EnrollStatus.Section) AS CrsYrSec,
-
((SUM(ISNULL(AssessedAmount, 0)) + SUM(ISNULL(tbl_AssessedFees.AdjustDebit,0))) - SUM(ISNULL(tbl_AssessedFees.AdjustCredit, 0))) AS AssessedAmt,
-
SUM(ISNULL(tbl_Payments.Amount, 0)) AS PaymentAmt,
-
((SUM(ISNULL(AssessedAmount, 0)) + SUM(ISNULL(tbl_AssessedFees.AdjustDebit,0))) - (SUM(ISNULL(tbl_AssessedFees.AdjustCredit, 0)) + SUM(ISNULL(tbl_Payments.Amount, 0)))) AS RemainingBalance
-
FROM tbl_Students.Id_No INNER JOIN tbl_CourseTaken ON tbl_Students.ID_No = tbl_CourseTaken.Id_No
-
INNER JOIN tbl_Curriculum ON tbl_CourseTaken.Curriculum_Code = tbl_Curriculum.Curriculum_Code
-
INNER JOIN tbl_Courses ON tbl_Curriculum.Course_Code = tbl_Courses.Course_Code
-
INNER JOIN tbl_EnrollStatus ON tbl_CourseTaken.Taken_Code = tbl_EnrollStatus.Taken_Code
-
INNER JOIN tbl_Enrollees ON tbl_EnrollStatus.Enroll_Code = tbl_Enrollees.Enroll_Code
-
INNER JOIN tbl_AssessedFees ON tbl_EnrollStatus.Enroll_Code = tbl_AssessedFees.Enroll_Code
-
LEFT JOIN tbl_Payments ON tbl_EnrollStatus.Enroll_Code = tbl_Payments.Enroll_Code
-
INNER JOIN tbl_ReceiptNo ON tbl_Payments.Receipt_Code = tbl_ReceiptNo.Receipt_Code
-
WHERE tbl_Enrollees.Schedule_Code = @schedCode AND
-
tbl_ReceiptNo.PayStatus = 'Valid'
-
GROUP BY tbl_Students.Id_No, LastName, FirstName, MiddleName, tbl_Courses.Abbreviation. tbl_EnrollStatus.YearLevel,
-
tbl_EnrollStatus.Section
-
ORDER BY tbl_Names ASC
1 1091
Are you sure the table contains data for desired output . Can you please post your table structures.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: lowellturner |
last post by:
We recently had to reload an app to a Linux server from its Window
counterpart. I've tried setting the lower case global in my.cnf to al
three values, but none work. Previously, this worked fine....
|
by: Ajay |
last post by:
hi All,
I am writing a java application which queries DB2. I need SQL queries
for following :
1. Query to check whether, the attributes for LOB columns like BLOB and
CLOB is "LOGGED" or not?...
|
by: Bill |
last post by:
Hello out there;
This may be a challenge but I'm certain it's possible but I can't seem
to figure out how.
I have a table that has several date fields, e.g., Date1, Date2,
Date3, Date4 ......
|
by: Michael |
last post by:
Hi,
I've read Scott's article:
http://weblogs.asp.net/scottgu/archive/2005/08/25/423703.aspx
but when I try to create a new database file in App_Data with
Visual Studio 2005, it shows error:
...
|
by: getkapilcs |
last post by:
Hi,
i want to query sql server using xml, where the required fields are to
be specified in the xml dynamically. can you tell me how to generate
such a xml file?
regards,
Kap
|
by: Karthik D V |
last post by:
Hello All,
I have a table like this
ID CHARACTER
----------- ---------
1 A
2 A
3 B
4 B
|
by: Access |
last post by:
In my user interface if a user doesn't have access to a field in the
database I lock it and make the background color yellow. Problem is
I'm maintaining permissions in two different places. On...
|
by: Dinesh |
last post by:
Hi,
Currenly we need SQL Server Database Admin, about 2 yrs of experience.
Position is based on Dubai and this is permanent position with
Carrefour (2nd largest Hypermarket after Walmart).
If...
|
by: jeffatncx |
last post by:
Hi all
ms Access 2003, SP2.
I write a SQL statement that unions some other queries and it works
ok. Then, if I save and close it and open the form that uses the query
as its data source, I get an...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
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
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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: 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,...
|
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...
|
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,...
| |