SQL中Having與Where的區別,sqlhavingwhere

來源:互聯網
上載者:User

SQL中Having與Where的區別,sqlhavingwhere

含義

where

在分組之前就進行選擇操作

having

having在分組操作之後才進行選擇操作,所以having可以選擇彙總函式
eg:

// 下面這句是可以的SELECT COUNT(*) FROM AWHERE A.a1>0GROUP BY a2;
//但是下面就不行SELECT COUNT(*) FROM AWHERE A.a1>0 and count(*)>1GROUP BY a2;
//必須要改為havingSELECT COUNT(*) FROM AWHERE A.a1>0GROUP BY a2HAVING COUNT(*)>1
您可能感興趣的文章:
  • SQL 中having 和where的區別分析
  • sql語句中where和having的區別

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.