Q1、Q2、Q3和Q4都存在审核结论这一列
时间: 2023-08-05 18:07:50 浏览: 143
好的,您可以使用以下代码来实现:
```csharp
using System.Data;
using System.Data.SQLite;
public DataTable QuerySQLite()
{
string connectionString = "Data Source=your_database_path";
string query = "SELECT COUNT(CASE WHEN Q1 IS NOT NULL THEN 1 END) AS Q1Count, COUNT(CASE WHEN Q2 IS NOT NULL THEN 1 END) AS Q2Count, COUNT(CASE WHEN Q3 IS NOT NULL THEN 1 END) AS Q3Count, COUNT(CASE WHEN Q4 IS NOT NULL THEN 1 END) AS Q4Count FROM your_table_name WHERE 审核结论 IS NOT NULL";
using (SQLiteConnection connection = new SQLiteConnection(connectionString))
{
connection.Open();
using (SQLiteCommand command = new SQLiteCommand(query, connection))
{
using (SQLiteDataAdapter adapter = new SQLiteDataAdapter(command))
{
DataTable dataTable = new DataTable();
adapter.Fill(dataTable);
return dataTable;
}
}
}
}
```
请确保替换 `your_database_path` 和 `your_table_name` 为您的数据库和表的名称。此代码将执行一个查询,计算每个列中的非空值的数量,并将结果作为 `DataTable` 返回。同时,`WHERE` 子句可用于仅计算包含审核结论的行。
阅读全文