Help for designing mysql query

Asked

Viewed 50 times

0

I have the following table in Mysql: Cod,D1,D2,D3,D4,D5,D6,D7,D8,D9,D10,D11,D12,D13,D14,D15 D1...D15 fields are filled with values between 1 and 25 in each record. There is no repetition of values within a record. How can I perform queries to find more frequent groups that repeat in the records? Example: identify how many times the group of values 1,5,10,15,20,25 appeared in the records. It would be possible to create a generic query to identify which groups had more frequency?

1 answer

0

I would say that this search summarizes the table information in order to obtain the intended.

SELECT
    case when d1=1 or 
                        d2=1 or 
    (...) 
                        d15=1
    then 1
    else 0 as dx1 count,
    case when d1=2 or
                         d2=2 or
     (...)
      then 1
      else 0 as dx2 count
(.....) 
from {table} ;

Browser other questions tagged

You are not signed in. Login or sign up in order to post.