Home > database >  MSSQL query check according to the results and analysis of the trade
MSSQL query check according to the results and analysis of the trade

Time:03-15

According to the result of the query such as I think

The select img, img_t img_s from tablename where imgtype='ybj' and houseid=112

If there is a record, access to the inside of the

If there is no record with this query
The select img, img_t img_s from tablename where imgtype='typeimg' and houseid=112

Which can use directly in the SQL query to get the final result, I do not know how to implement, please tall person to give directions, thank!

CodePudding user response:

The problem yesterday? Either you post some test data, and then set forth the expectation result, let the others will help you,

CodePudding user response:

reference 1st floor RINK_1 response:
didn't solve the problem? Either you post some test data, and then set forth the expectation result, let the others will help you,


Thank you, well will have resolved the dense_rank () to switch to ROW_NUMBER () is the perfect solution, are the requirements for a product manager, in door cover, take cover if there is a door cover, not the building dish between example in figure, the figure between example can be multiple, so use ROW_NUMBER () settled, query seems a little complicated, so want to use more original judgment to realize, may later only to protect more simple point
The effect of this is to use ROW_NUMBER ()

This is to use dense_rank ()

CodePudding user response:


If the exists (select img, img_t img_s from tablename where imgtype='ybj' and houseid=112)
The select img, img_t img_s from tablename where imgtype='ybj' and houseid=112
The else
The select img, img_t img_s from tablename where imgtype='typeimg' and houseid=112
  • Related