sql server - this sql query works in mysql but not in mssql -


mysql:

select *  (select * songs order artist asc) songs2  artist 'a%' group artist` 

mssql:

select *  (select top 1000 * songs order artist asc) songs2   artist 'a%' group artist 

this works in mysql in mssql error:

column 'songs2.id' invalid in select list because not contained in either aggregate function or group clause

++++++++++++++++++ select query : select artist,album,song (select top 1000 * songs order year asc, artist asc) songs2 artist 'a%' group artist,album,song; not group artist, want 1 artist per song available in query

this find 1 song per artist , maximum of 1000 songs:

select top 1000    artist,album,song   (   select      artist,album,song,      row_number() on (partition artist order (select 1)) rn   table_name    artist 'a%'  ) t2  rn = 1 

Comments

Popular posts from this blog

qt - Using float or double for own QML classes -

Create Outlook appointment via C# .Net -

ios - Swift Array Resetting Itself -