Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在编写一个 ASP.NET 页面。我正在尝试编写一个查询来获取列中存在特定值的总次数:
餐桌课程:
CourseSubject -------------- ECT HCI HCI
我只想返回 name2 出现的次数。
到目前为止我有这个但不断收到错误:
comm.CommandText = "SELECT CourseSubject, COUNT(*) AS ETC FROM Courses;
SELECT CourseSubject, COUNT(*) AS ETC FROM Courses Group BY CourseSubject
这为您提供了表中所有课程的计数
如果你只想要一个特定的计数,你可以这样做
SELECT COUNT(1) AS ETC FROM Courses WHERE CourseSubject = 'Name2'