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

  • SEARCH
  • Home
  • 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 8926911
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T08:06:01+00:00 2026-06-15T08:06:01+00:00

l have the following table and data and expected output with my rules drop

  • 0

l have the following table and data and expected output with my rules

drop table test_new

create table test_new (id number(9), loc1 number(9), loc2 number(9), percentage number(9));

insert into test_new values (1,1,2,0);
insert into test_new values(2,1,3,10);
insert into test_new values(3,1,4,5);
insert into test_new values(4,1,5,45);
insert into test_new values(5,2,3,0);
insert into test_new values(6,2,4,90);
insert into test_new values(7,2,5,0);
insert into test_new values(8,3,4,0);
insert into test_new values(9,3,5,0);
insert into test_new values(10,4,5,40);
insert into test_new values(11,7,5,0);
insert into test_new values(12,9,4,0);
insert into test_new values(13,10,5,90);
insert into test_new values(14,11,5,70);
insert into test_new values(15,1,15,45);

in need this form The query show that

id  loc1 loc2  percentage
15    1    15       45
2    1    3       10
6    2    4       90
13   10   5       90

Not this one

id   loc1 loc2  percentage
2    1    3       10
15    1    15      45
6    2    4       90
13   10   5       90

Rules:

  1. show id, loc1, loc2, percentage where percentage greater than zero.
  2. remove any redundance of data in column loc2 so the remove row that has lower value of percentage.
  3. sort data based on percentage asc and group it based column loc1.
  • 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-15T08:06:03+00:00Added an answer on June 15, 2026 at 8:06 am

    Give this a try.

    select t1.* from test_new t1
    left join test_new t2
    on t1.loc2 = t2.loc2 and t1.percentage < t2.percentage
    where t1.percentage > 0 and t2.loc2 is null
    order by t1.percentage
    

    However, I think that based on your comments (not on your result table, which seems to be wrong), this is what you’re expecting:

    +----+------+------+------------+
    | ID | LOC1 | LOC2 | PERCENTAGE |
    +----+------+------+------------+
    |  2 |    1 |    3 |         10 |
    | 15 |    1 |   15 |         45 |
    |  6 |    2 |    4 |         90 |
    | 13 |   10 |    5 |         90 |
    +----+------+------+------------+
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following table: CREATE TABLE [dbo].[Data] ( [Id] UNIQUEIDENTIFIER NOT NULL, [Data]
Suppose we have the following table data: ID parent stage submitted 1 1 1
I have the following table and data docRefID docExternalContent 1 'a' 1 'b' 1
I have the following table template that is rendered through knockout: <table class=gv data-bind=visible:
I have the following table: ID | JobID | Data | ResultType --------------------------------- 1
I have following data in my table. alt text http://img26.imageshack.us/img26/3746/productfield.png I want to extract
I have following data in excel table r1 r2 r3 r4 r5 v1 v2
I have some data in a table that looks roughly like the following: table
I have the following data on a table tbl Admission : Date and Time
I have test_scores table with following fields: Table schema: id (number) score1 (number) score2

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.