问题描述
我有问题,我不知道怎么解决这个问题帮我做这个....
这是保存在我的sql数据库中的数据
--------------------
ID | BloodGroup
--------------------
1 | A
2 | B
3 | A
4 | AB
5 | B
6 | O
7 | A
8 | AB
但是我的数据表示完全不同我可以完成这种操作。
----------------------------------------
A | B | AB | O
----------------------------------------
3 | 2 | 2 | 1
i have issue and i dont knw how to solve this issue help me to do this ....
this is data saved in my sql database
--------------------
ID | BloodGroup
--------------------
1 | A
2 | B
3 | A
4 | AB
5 | B
6 | O
7 | A
8 | AB
but my representation of data is totally different how i can perfom this kind of operation.
----------------------------------------
A | B |AB| O
----------------------------------------
3 | 2 |2 | 1
推荐答案
SELECT A,B,AB,O
FROM
(SELECT bloodgroup FROM table1) AS src
PIVOT
(
COUNT(bloodgroup) FOR bloodgroup IN (A,B,AB,O)
)AS piv
这篇关于如何在Windows应用程序中使用Datagridview或listview将行显示为列名。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!