SQL query returning same value for both tables colums -
select (count(v1.id) * 2) + (count(v2.id) * 0.5) total, count(v1.id) votes, count(v2.id) visits votes v1, visits v2 ;
actually query results in 1710 votes , visits votes has 18 rows , visits 98... know why? , has solution?
the correct return values be:
total of 85
18 votes
98 visits
current structure:
http://sqlfiddle.com/#!2/b7604/1
try,
select sum(visitscount) + sum(votescount) total, sum(visitscount) visits, sum(votescount) votes ( select count(id) votescount, 0 visitscount, 1 gr votes union select 0 votescount, count(id) visitscount, 1 gr visits ) t group gr
check sql fiddle
Comments
Post a Comment