Note that there are some explanatory texts on larger screens.

plurals
  1. PONeed help for complex data sort SQL Server
    primarykey
    data
    text
    <p>I need help for complex data sort from database. Suppose my data stored in table like this:</p> <pre><code>Description -------------- JCB Excavator - ECU P/N: 728/35700 Geo Prism 1995 GEO - ABS #16213899 GEO pump Geo Prism 1995 - GEO ABS #16213897 Geo Prism 1995 - ABS #16213897 Ersatz Airbags, Gurtstrammer und Auto Körper Teile this test JCB pipe &amp; JCB pump Wie man BBA reman erreicht </code></pre> <p>7 rows are there. I want to write a SQL query in such a way as a result it will sort data based on my input word. Suppose my search term is <code>GEO,JCB</code> two words together separated by comma. The rows that will come first are those where search word found maximum time. So for <code>GEO</code> the word has the maximum time in most of the rows. </p> <p>Two sorts will be required:</p> <ul> <li>first sort data in such way where search term found maximum time.</li> <li>second sort data on the basis maximum occurrence of search term found in each rows.</li> </ul> <p>Suppose <code>GEO</code> the search term found in maximum row.</p> <p>So all the rows that have <code>GEO</code> keyword will come first and then <code>JCB</code> related data will come.</p> <p>In <code>GEO</code> related data those rows will come first that have maximum <code>GEO</code> keyword.</p> <p>So the output will be look like.</p> <pre><code>Description -------------- Geo Prism 1995 GEO - ABS #16213899 GEO pump Geo Prism 1995 - GEO ABS #16213897 Geo Prism 1995 - ABS #16213897 this test JCB pipe &amp; JCB pump JCB Excavator - ECU P/N: 728/35700 Ersatz Airbags, Gurtstrammer und Auto Körper Teile Wie man BBA reman erreicht </code></pre> <p>Please help me to construct this kind of sql which will work in all SQL Server version.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload