簡體   English   中英

我怎樣才能 output 包含在 SQL 中匹配此條件的所有項目的計數的表?

[英]How can I output a table containing the count of all items that match this condition in SQL?

我在 CS50 pset7 SQLite 查詢中工作,我陷入了這個問題: write a SQL query to determine the number of movies with an IMDb rating of 10.0. Your query should output a table with a single column and a single row (plus optional header) containing the number of movies with a 10.0 rating. write a SQL query to determine the number of movies with an IMDb rating of 10.0. Your query should output a table with a single column and a single row (plus optional header) containing the number of movies with a 10.0 rating. 所以基本上我要做的就是將 go 放入一個名為“評級”的表中, 表結構

它具有上圖的結構,並獲取列 rating 中有多少項的值為10.0

我試過count(SELECT * FROM ratings WHERE rating=10.0但我相信 count 不是那樣工作的......

希望你能幫助我! 謝謝!

試試下面 -

   select count(*)
     FROM ratings WHERE rating=10.0

為了返回表的行數,我們使用 count(*) SQL 的 function。
Select count(*) from ratings where rating where rating = 10.0;

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM