I have three tables(W,P,Q) each connected to the Primary key of another table(S). In order to calculate a field, I need to get data from the three tables(W,P,Q). I know that in SQL Server you can only create a calculated column with data from the SAME table.
I was wondering if there's any other way to solve my problem without merging the three tables into one. I had a project in Access with the same requirements and I was able to solve this problem using a query. I was trying to create a query in SQL server similar to what I did in Access, but I don't know how to add a column with formula in SQL Server queries.
I'm also using vb.net for the front-end of my application. So I also need to be able connect what I want to do in DataGridView Any suggestions would be helpful and sorry for any mistakes I'm new in stackoverflow and SQL server.
ACCESS VERSION:
SELECT
tblStudent.stud_LRN,
tblStudent.stud_Lname,
tblStudent.stud_Fname,
[tblPerformanceTask]![perf_WS]+[tblQuarterlyAssessment]![quart_WS]+[tblWrittenWork]![writ_WS] AS InitialGrade,
IIf([InitialGrade]<60,60+15* ([InitialGrade]/60),75+25*([InitialGrade]-60)/40) AS QuarterGrade,
tblStudent.stud_rec_ID
FROM
((tblStudent
INNER JOIN tblPerformanceTask ON
tblStudent.stud_rec_ID = tblPerformanceTask.Stud_Rec_ID)
INNER JOIN tblQuarterlyAssessment ON
tblStudent.stud_rec_ID = tblQuarterlyAssessment.stud_rec_ID)
INNER JOIN tblWrittenWork ON
tblStudent.stud_rec_ID = tblWrittenWork.stud_rec_ID;
SQL SERVER VERSION:
SELECT
S.Stud_LRN,
S.Stud_LName,
S.Stud_FName,
W.writ_PS,
W.writ_WS,
P.perf_PS,
P.perf_WS,
Q.quart_PS,
Q.quart_WS
FROM
tblStudent AS S
INNER JOIN tblWrittenWork AS W ON S.Stud_rec_ID = W.Stud_ID_FK
INNER JOIN tblPerformanceTask AS P ON S.Stud_rec_ID = P.Stud_ID_FK
INNER JOIN tblQuarterlyAssessment AS Q ON S.Stud_rec_ID = Q.Stud_ID_FK