猿问

关于Group问题

<P>PKId Title Datatime B_PIKd</P> <P>1&nbsp;title&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;NULL&nbsp; &nbsp;2<BR>2&nbsp;title&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;NULL&nbsp;&nbsp; 1<BR>3&nbsp;title&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;NULL&nbsp;&nbsp; &nbsp;2<BR>4&nbsp;title&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;NULL&nbsp;&nbsp; 3<BR>5&nbsp;title&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;NULL&nbsp; &nbsp;3<BR>6&nbsp;title&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;NULL&nbsp;&nbsp; 3<BR>7&nbsp;title&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;NULL&nbsp;&nbsp; 3<BR>8&nbsp;title&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;NULL&nbsp; &nbsp;1</P> <P>&nbsp;</P> <P>select * from News group by B_PKId&nbsp; 这条为什么报错</P> <P>消息 8120,级别 16,状态 1,第 1 行<BR>选择列表中的列 'News.PKId' 无效,因为该列没有包含在聚合函数或 GROUP BY 子句中。</P>

繁花如伊
浏览 662回答 2
2回答

12345678_0001

GROUP BY 是配合聚合语句用的 select count(*) , B_PKId from News group by B_PKId 只group by中能够不用聚合函数表示的只有被group by 的项
随时随地看视频慕课网APP

相关分类

SQL Server
我要回答