I create a table in Amazon Redshift using the following command:
CREATE TABLE asmt.incorrect_question_pairs_unique AS SELECT question1, question2, occurrences, occurrences / (SUM(occurrences)::FLOAT) OVER () AS prob_q1_q2 FROM (SELECT question1, question2, SUM(occurrences) AS occurrences FROM asmt.incorrect_question_pairs GROUP BY question1, question2 HAVING SUM(occurrences) >= 50)
I also tried the option:
CREATE TABLE asmt.incorrect_question_pairs_unique AS SELECT question1, question2, occurrences, occurrences::float / SUM(occurrences) OVER () AS prob_q1_q2 FROM (SELECT question1, question2, SUM(occurrences) AS occurrences FROM asmt.incorrect_question_pairs GROUP BY question1, question2 HAVING SUM(occurrences) >= 50)
I would like the prob_q1_q2 column to be a float column, so I am converting the denominator / numerator to float . But in the summary table, I get all the zeros in this column.
I would like to point out that SUM(occurrences) will be around 10 Billion , so the prob_q1_q2 column will contain extremely small values. Is there a way to keep such small values ββin Amazon Redshift ?
How to make sure all values ββin a column are non-zero float ?
Any help would be appreciated.
source share