Note that there are some explanatory texts on larger screens.

plurals
  1. POSearching and displaying results by relevance in Oracle
    primarykey
    data
    text
    <p>I am very beginner to Oracle Database query development. I am developing a search functionality for my project to search for Stores by <strong>Zip</strong> or <strong>Name</strong> or <strong>City</strong>, where the user will be provided with "One HTML input box" to enter the search term. There is only table Called Stores</p> <p>The conditions for displaying search results are</p> <ol> <li>If the search term matched to <code>ZIP</code> results should be <code>GROUP</code> and <code>SORT BY ZIP DESC</code></li> <li>If the search term matched to <code>NAME</code> results should be group and sort by <code>NAME IN ASC</code> and same as to <code>CITY</code></li> <li>If the search term matched to <code>ZIP</code>,<code>NAME</code> and <code>CITY</code> (to all), then first the results matched to the <code>ZIP</code> should be displayed in <code>DESC order</code>, next <code>CITY</code> followed by The <code>NAME</code></li> </ol> <p>I have tried Some thing like this </p> <pre><code>SELECT s.uuid AS uuid, COUNT(*) over() AS rowcount FROM Stores s WHERE s.postalcode LIKE '%87%' OR s.city LIKE '%87%' OR CONCAT(CONCAT(s.firstname, ' '),s.lastname) LIKE '%87%' GROUP BY s.city, s.postalcode, CONCAT(CONCAT(s.firstname, ' '),s.lastname), s.uuid ORDER BY CASE WHEN s.postalcode LIKE '%87%' THEN s.postalcode END DESC, CASE WHEN CONCAT(CONCAT(s.firstname, ' '),s.lastname) LIKE '%87%' THEN CONCAT(CONCAT(s.firstname, ' '),s.lastname) ELSE s.postalcode END ASC, CASE WHEN s.city LIKE '%87%' THEN s.city END </code></pre> <p>This query is not displaying the results as expected (I mean it is displaying results without order, not Like First zip, next city followed by name). </p> <p>How can I do the query to meet the above requirements, do I need to use stored procedures to do that ? Any suggestions will be greatly appreciated.</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.
    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