Crosstab with a large or undefined number of categories

后端 未结 3 508
野的像风
野的像风 2020-12-05 21:54

My real problem has to do with recording which of a very large number of anti-virus products agree that a given sample is a member of a given anti-virus family. The databas

3条回答
  •  悲&欢浪女
    2020-12-05 22:15

    Your wish implies transfering some of the data (the names) into column headings, i.e. the schema of the resulting table. As this is somewhere between inconvenient and impossible, I would recommending just sorting and summing the data in sql, and doing the rest outside of the database.

    SELECT Photo, Voter
    FROM data
    WHERE Decision = '...'
    ORDER BY Photo, Voter
    

    and

    SELECT Photo, COUNT(*) AS Total
    FROM data
    WHERE Decision = '...'
    GROUP BY Photo
    ORDER BY Photo;
    

提交回复
热议问题