> > > Lets take an eg: > ------------- > 1) p_details.project_no = 1005, p_details.quantiuty = 500 > 2) s_details.project_no = 1005, s_details.quantiuty = 100 > 3) s_details.project_no = 1005, s_details.quantiuty = 300 > > Logically i should get P_SUM = 500 and S_SUM = 400. > But, i get P_SUM = 1000 and S_SUM = 400 which is wrong. > > So, my P_SUM is multiplied by number of times of s_details records. > > How can i manage to write this in SQL without using SUB queries?
I think you'll need to sum p_details.quantity, sum s_details.quantity first, in individual queries, ordered and grouped by project_no, then total those two sums in a seperate query or array manipulation. [Non-text portions of this message have been removed] --------------------------------------------------------------------- Home : http://groups.yahoo.com/group/active-server-pages --------------------------------------------------------------------- Post : [email protected] Subscribe : [EMAIL PROTECTED] Unsubscribe: [EMAIL PROTECTED] --------------------------------------------------------------------- Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/active-server-pages/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/
