Skip to content

Instantly share code, notes, and snippets.

@Haguilar91
Created November 4, 2019 19:32
Show Gist options
  • Save Haguilar91/992e35d527083c69683b5b5cee6cd8f3 to your computer and use it in GitHub Desktop.
Save Haguilar91/992e35d527083c69683b5b5cee6cd8f3 to your computer and use it in GitHub Desktop.
int acum_help=0;
int acum_unhelp=0;
int question_id=0;
int question_id_starter=0;
for (int i = 0 ;i < table.rowlength; i++ )
if(i=0)
question_id_starter = row.question_id
endif
if (row.is_useful = 1)&& (question_id_starter==row.questionid)
acum_help ++;
else if (question_id_starter==row.questionid)
acoum_unhelp++;
else
question_id_starter = row.question_id
INSERT INTO temp_ratings (question_id,acum_help,acum_unhelp) VALUES (question_id,acum_help,acum_unhelp);
acum_help = 0
acum_unhelp = 0
endif
if(i=table.rowlenght)
INSERT INTO temp_ratings (question_id,acum_help,acum_unhelp) VALUES (question_id,acum_help,acum_unhelp);
endif
endfor
select
count(*) as count_flagged
from temp_ratings
where (unhelpful>helpful)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment