我正在尝试对查询结果进行分组并在不同的列中显示。
表名:category_results
+---------+-----------------+
| cat_id | Total |
+---------+-----------------+
| CA001 | 150.00 |
| CA002 | 130.00 |
| CA002 | 200.00 |
| CA003 | 70.00 |
| CA001 | 75.00 |
+---------+-----------------+
我想要这个结果:
+--------+--------+--------+
| CA001 | CA002 | CA003 |
+--------+--------+--------+
| 255.00 | 330.00 | 70.00 |
+--------+--------+--------+
有什么想法吗?
答案 0 :(得分:2)
您可以使用private const string fileName = "ServerData.xml";
public void ProcessBuffer(byte[] receiveBuffer, int bytes)
{
if (!File.Exists(fileName))
{
using (File.Create(fileName)) { };
}
TextWriter tw = new StreamWriter(fileName, true);
tw.Write(Encoding.UTF8.GetString(receiveBuffer).TrimEnd((Char)0));
tw.Close();
}
结合SUM
来实现您的目标:
CASE WHEN
点击下面的链接查看正在运行的演示。