Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

get wrong answer from sql

first `

Select Count(*) From Covids Where AsiDurumu=1

I get 12 from first query

Second

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Select MAX(covidId) From Covids 

I get 18 from second query

Third Query

Select CAST(Count(*) AS FLOAT) / MAX(CovidId) as Asi_Olanlarin_Covid_Orani From Covids Where AsiDurumu=1

when i wrote this query i got 0.705858.. but i must get 0.66. why i didn’t get

>Solution :

Use a case expression to do conditional aggregation:

Select sum(case when AsiDurumu = 1 then 1.0 else 0.0 end ) / MAX(CovidId) as Asi_Olanlarin_Covid_Orani
From Covids
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading