public double getDataTypePercentageSingleKey(String key, int dataType){

        double res = 0;

        String[] attributes = key.split(",");
        String selectClause = "SELECT ";
        String caseClause = "CASE ";
        String when1 = "";
        String when2 = "";
        String when3 = "";
        String fromClause= "FROM ";
        String whereClause = "WHERE ";

        /*for(int i = 0; attributes.length > i; i++){
            selectClause += "at" + (i+1) + ".content a" + (i+1) + ", at" + (i+1) + ".data_type dt" + (i+1) + ",";
        }*/

        if(attributes.length == 1){
            selectClause += "at1.data_type dt_final ";
            caseClause = "";
            fromClause += "(SELECT * FROM DBLOAD D where attribute='" + attributes[0] + "' AND data_type!=-1) as at1 ";
            whereClause += "at1.obj_index=at1.obj_index";

        }
        else{
            for(int i = 0; attributes.length > i; i++){

                if((i+1)==1){
                    when1 +="WHEN at" + (i+1) + ".data_type=3 ";
                    when2 +="WHEN at" + (i+1) + ".data_type=2 ";
                    when3 +="WHEN at" + (i+1) + ".data_type=1 ";
                }
                else{
                    if((i+1)==2){
                        when1 +=" OR at" + (i+1) + ".data_type=3 ";
                        when2 +="THEN CASE WHEN at" + (i+1) + ".data_type=1 ";
                        when3 +="THEN CASE WHEN at" + (i+1) + ".data_type=2 ";
                    }
                    else{
                        when1 +=" OR at" + (i+1) + ".data_type=3 ";
                        when2 +="OR at" + (i+1) + ".data_type=1 ";
                        when3 +="OR at" + (i+1) + ".data_type=2 ";
                    }
                }

            }
            when1+="THEN 3 ";
            when2+="THEN 3 ELSE 2 END ";
            when3+="THEN 3 ELSE 1 END ";
            caseClause += when1 + when2 + when3 + "END dt_final ";

            for(int i = 0; attributes.length > i; i++){
                fromClause += "(SELECT * FROM DBLOAD D where attribute='" + attributes[i] + "' AND data_type!=-1) as at" + (i+1) + " ,";
            }
            fromClause = fromClause.substring(0,fromClause.length()-1);


            for(int i = 1; attributes.length+1 > i; i++){
                for(int j = i+1; attributes.length+1 > j; j++){
                    whereClause += "at" + i + ".obj_index=at" + j + ".obj_index AND ";
                }      
            }
            whereClause = whereClause.substring(0,whereClause.length()-5);

        }

        try{

            String query = "CREATE TABLE KeyDataTypeAux " + selectClause + caseClause + fromClause + whereClause;

            ps = conn.prepareStatement(query);
            System.out.println(query);

            ps.execute();

            query = "SELECT (SELECT COUNT(*) FROM KeyDataTypeAux WHERE dt_final=" + dataType + ")/(SELECT COUNT(*) FROM KeyDataTypeAux)";
            System.out.println(query);

            ps = conn.prepareStatement(query);

            ResultSet rs = ps.executeQuery();

            if(rs.next()){
                res = rs.getDouble(1);
            }

            query = "DROP TABLE KeyDataTypeAux";

            ps = conn.prepareStatement(query);

            ps.execute();

            rs.close();
            ps.close();

        }catch(SQLException sqle){sqle.printStackTrace();}

        return res;

    }