当前位置: 代码迷 >> Sql Server >> SQL 嵌套查询,该如何处理
  详细解决方案

SQL 嵌套查询,该如何处理

热度:67   发布时间:2016-04-24 21:49:19.0
SQL 嵌套查询
请问各位以下这条查询语句应该怎么改?
表中记录了多个街道,每一个街道都有多个场所,请问怎么把所有街道中每一个街道里面有多少个场所查出来?
select count(pComname) from tbl_Product where pStreet=(select distinct pStreet from tbl_Product)
错误:子查询返回的值不止一个。当子查询跟随在 =、!=、<、<=、>、>= 之后,或子查询用作表达式时,这种情况是不允许的。
SQL select

------解决方案--------------------
select count(pComname) from tbl_Product where pStreet in (select distinct pStreet from tbl_Product)
  相关解决方案