sql - Alphabetic ranking a list with set of 'WITH TIES - ORDER BY (multiple fields) -


a regular usage of "with ties" & result of query :

demand: best of 10 movies oscar wins

select  top 10 ties  f.filmname title,                       f.filmoscarwins [oscar wins]                        dbo.tblfilm f                       filmoscarwins not null                       order  [oscar wins] desc; 

resullt of first query

when add "title" @ field of order make list alphabetical order, doesn't work properly!

  • no 13 movies in list

  • no alphabetic order

demand: best of 10 movies in alphabetical order:

select  top 10 ties  f.filmname title,                       f.filmoscarwins [oscar wins]                        dbo.tblfilm f                       filmoscarwins not null                       order  [oscar wins] desc, title; 

result of second query

so should make alphabetical order while ranking set of 'with ties - order by'?

your query gets top 10 ranked oscar winning movies. top 10 , order by in query.

now want use data set , show in order. means additional query own order by clause:

select * (   select top 10 ties     f.filmname title,     f.filmoscarwins [oscar wins]    dbo.tblfilm f   filmoscarwins not null   order [oscar wins] desc ) top10 order title; 

Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -