question

adilahana avatar image
adilahana asked

sum for two column in one table

i had one table farm. 4 column; id, refer_no, state and area. i am trying to find overall farmer and area in states. before i run my query, i total up the value in excel first to make sure the data is same as the output. however the value is not same. i did try query it separately to find which part is wrong, but the result is still same. below is my query;

if i lack any information, please guide me. i really appreciated it.

SELECT SUM(totalfarmer) AS overallfarmer, SUM(totalarea) AS overallarea
from ( select state,COUNT(DISTINCT(refer_no)) AS totalfarmer,
SUM(area) AS totalarea 
FROM farm GROUP BY state ) 
as overallx
sumtotal
10 |1200 characters needed characters left characters exceeded

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

0 Answers

· Write an Answer

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.