I'm trying to write a Kusto query to get the [x] in each [y] with the most [z]. To be more specific, I'm querying the Azure Data Explorer sample table Covid to find the state with the most deaths in each country. I've tried this:
Covid19
| where State <> ""
| summarize deaths = max(Deaths) by State, Country
| project Country, State, deaths
| order by deaths
which runs, but produces multiple states from the same country. I also tried this:
Covid19
| where State <> ""
| summarize deaths = max(Deaths) by State, Country
| summarize deths = max(deaths) by State
| project Country, State, deths
But then I get an error on the last line "The name 'Country' does not refer to any known column...".
I also tried this:
Covid19
| where State <> ""
| summarize deaths = max(Deaths) by State, Country
| summarize deths = max(deaths) by Country
| project Country, deths
Which seems to produce correct results, but then I can't display the state. So it seems like I'm getting a runaround where I have either too much info or not enough.
Actual results from first query:
Expected results: