Sql查询计数/集合|从查询中获取整数|显示到图表C# [英] Sql query count/groupe | get integer out of query | display to chart C#
问题描述
大家好,
先让我描述一下我想做的事情:
我想在mysql数据表中显示条目的频率到图表
(条形图)。
例如,该表包含条目:5次entry1,8次entry2和15次entrie3。我想将它显示到图表(条形图)。我想你可以想象它会是什么样子。 X轴包含每个条目的名称,条形的高度表示该条目的频率。我需要按频率对条形图进行排序(大多数记录的条目首先)
有人可以告诉我是否有一种简单的方法可以做到这一点?我不知道最好的方法是计算条目并将计数提取为整数。无论如何,我不知道如何做到这一点。也许有一种直接的方法将图表连接到mysql数据库并以所需的方式显示数据?
如果有人给你一个建议,我将不胜感激,非常感谢。
我的尝试:
sql陈述:Count,Groupe by,DESC
阅读C#中的图表
Hi to everybody,
first let me describe what i want to do:
I want to display the frequency of the entries in a mysql datatable to a chart
(bar graph).
For example the table contains the entries: 5 times entry1, 8 times entry2 and 15 times entrie3. I want to display that to a chart(bar graph). I think you can image how it would look like. The X-Axis contains the names of each entry and the height of the bar represents the frequency of that entry. I need to sort the bars by frequency (most recorded entry first)
Can somebody tell me if there is an easy way to do this? I dont know if the best way is to count the entries and extract the count number to an integer. Anyway i have no clue how to do this. Maybe there is a direct way to connect a chart to a mysql database and display the data in the desired way?
I would appreciate it if somebody would give ma a suggestion, Thanks a lot.
What I have tried:
sql statements: Count, Groupe by, DESC
Reading about Charts in C#
推荐答案
尝试:
Try:
SELECT Frequency, COUNT(*) FROM MyTable GROUP BY Frequency
通过SqlDataAdapter将其加载到DataTable中,并将其传递给您的图表,或转换为包含X和Y数据的对象集合。
这可能会有所帮助:使用带有多行集合的图表 [ ^ ]
Load that into a DataTable via an SqlDataAdapter, and pass that to your chart, or convert it to a collection of objects which contains the X and Y data.
This may help: Using a Chart With Multiple Lines From A Collection[^]
这篇关于Sql查询计数/集合|从查询中获取整数|显示到图表C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!