简体   繁体   中英

Select Rows based on Where Condition but group them based on a specific Column value

I want to Select some rows from the database based on my where clause and group them based on some condions.

I have done this till now

SELECT col1, Encounter.EncounterId, col2, col3 FROM Abcd
Where SomeCondition
GroupBy Encounter.EncounterId

Returns an error is:

not contained in an aggregate function or the group by clause.

Try this :

 SELECT col1, Encounter.EncounterId, col2, col3 FROM Abcd
 Where SomeCondition
 GroupBy col1, Encounter.EncounterId, col2, col3

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM