sql server - Select Only first row from the join result -


i have stored procedure using below 2 tables

ticket nav group(table) -   column:  ticket type id ticket nav group id   ticket sorting(table) -   column :  ticket typeid, nav groupid, priority 

i did inner join between these tables. using ticket type id

since ticket type id , navgroup id , priority different, have found duplicate row .

now requirement need select first matching row result each ticket type id .

also need display ticket type id , priority in result

if have multiple ticket typeid in second table, can join this:

select      a.[ticket type id], a.[ticket nav group id], b.[priority]      [ticket nav group] inner join (             select [ticket typeid], max([priority])              [ticket sorting]             group [ticket typeid]         ) b          on b.[ticket typeid] = a.[ticket type id] 

and if understand right, think have table design issue.


Comments

Popular posts from this blog

sequelize.js - Sequelize group by with association includes id -

android - Robolectric "INTERNET permission is required" -

java - Android raising EPERM (Operation not permitted) when attempting to send UDP packet after network connection -