

I have the above table namely departmentRequisition and departmentRequisitionDetail respectively.
From the departmentRequisitionDetail, there is a column - departmentRequisitionId - 112 and many rows of acutalQuanity that I need to add up as a total quantity to display as a pie chart.
Now, in order to know the department that ties to this total qauntity, I need to refer to another table - departmentRequisition which shows the deparmentId - 2 which ties to this departmentRequisitionId.
Can someone advise how should I write the query so that I can generate the pie chart ?
The above is just for one departmentId and I need to have different departmentId showing the acutalquanity which is the quantity they ordered.
Or is there a better way to generate my crystal report based on the scenario above ? Like create another table to make things easier.

Nitin SontakkeRank #264 · 9.6K reputationPosted Sep 20, 2016, 1:16 AM EDT
Nitin SontakkeRank #264 · 9.6K reputationPosted Sep 19, 2016, 1:19 AM EDT
Tangara GRank #4,983 · 316 reputationPosted Sep 19, 2016, 7:07 AM EDT
departmentRequisition(PK, int, not null)
departmentRequestCode(nvarchar, not null)
disbursementCode(nvarchar, not null)
departmentId(int, not null)
status(nvarchar, not null)
createdDate(datetime, not null)
the columns for departmentrequisitiondetail are :
departmentRequisitionDetailId(PK, int, not null)
departmentRequisitionId(FK, int, not null)
itemId(FK, int, not null)
neededQuantity(int, not null)
actualQuantity(int, not null)
Nitin SontakkeRank #264 · 9.6K reputationPosted Sep 19, 2016, 9:03 AM EDT
Nitin SontakkeRank #264 · 9.6K reputationPosted Sep 19, 2016, 7:21 PM EDT
Bikesh SrivastavaRank #108 · 20.3K reputationPosted Sep 19, 2016, 11:01 PM EDT
Tangara GRank #4,983 · 316 reputationPosted Sep 19, 2016, 11:39 PM EDT
Nitin SontakkeRank #264 · 9.6K reputationPosted Sep 19, 2016, 11:54 PM EDT
Tangara GRank #4,983 · 316 reputationPosted Sep 20, 2016, 12:59 AM EDT
from departmentRequisitiondetail dr inner join departmentRequisition drd on dr.departmentRequisitionId = drd.departmentRequisitionId
group by dr.departmentRequisitionId, drd.departmentId order BY departmentRequisitionId DESC