Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8617895
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T05:58:43+00:00 2026-06-12T05:58:43+00:00

I am practicing some examples in Oracle as i am new to it. I

  • 0

I am practicing some examples in Oracle as i am new to it. I want to display the rows that are matched to First WHERE clause at beginning and last matched WHERE clause rows at last of below table.

  CREATE table demo(id int, name varchar(50), city varchar(20), zip varchar(20));
    insert into demo values(1,'oliver71','munich','85716');

    insert into demo values(2,'markus71','munich','85716');
    insert into demo values(3,'oliver81','stuttgart','70024');
    insert into demo values(4,'peter82','hale','81978');
    insert into demo values(5,'chinnarose71','rosenheim','80324');
    insert into demo values(6,'guru11','berlin','81982');
    insert into demo values(7,'sachin51','frankfurt','00712');

    select name, city, zip from demo where zip like '%7%' OR city LIKE '%7%' 
     OR name LIKE '%7%';

How can i do that in Oracle. Any suggestions will be greatly appreciated.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T05:58:45+00:00Added an answer on June 12, 2026 at 5:58 am

    There is no “WHEN” clause in your query. I assume you mean the parts of the WHERE clause.

    To do this, you need a way of ordering the results. Here is one way using a subquery, which I think might be the clearest:

    select name, city, zip
    from (select name, city, zip,
                 (case when zip like '%7%' then 1
                       when city LIKE '%7%' then 2
                       when name LIKE '%7%' then 3
                       else 0
                  end) as matchitem
          from demo
         ) d
    where matchitem > 0
    order by matchitem
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am very new to Oracle, While i am practicing some examples i encountered
I'm practicing some simple 2D game programming, and came up with a theory that
I am practicing TDD for some time now, I want to advance my skills
I was just practicing some coding and noticed that I was able to use
I am new to PHP, and I am practicing with some online tutorials. I
I'm practicing some examples on model-view programming and have a query why the colors
I was practicing some programming problems and tried to code the popular reverse words
I have been practicing TDD and (some) XP for a few years now and
I'm practicing my knowledge of ADTs by implementing some data structures, even if most
I have started practicing TDD approach. I am pretty much new to unit testing.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.