//compute percentage for Parent1

DecimalFormat df = new DecimalFormat("#.##%");
rs = s.executeQuery("SELECT "
+ "(SELECT COUNT(*) FROM genetic.blood_type where diseases = '" + disease1 + "')"
+ "/COUNT(*) AS rowcount FROM genetic.blood_type where btype = '" + btype1 + "'");
rs.next();
int result = rs.getInt("rowcount");
rs.close();
out.println(disease1 + " is " + df.format(result) +" "+ result);

i have a code right at the top .. having difficulty in displaying the result in decimal. its alwys giving me zero.. ive tried this in mysql

SELECT
(SELECT COUNT()FROM genetic.blood_type where diseases = "Heart Disease")
/COUNT(
) AS rowcount2 FROM genetic.blood_type where btype = "AB" ;

and i get the right answer..

not xur where i went wrong..

got it myself..

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.