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 6387157
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:06:59+00:00 2026-05-25T03:06:59+00:00

I have two tables table1 and table2 table1 has the columns: id name value

  • 0

I have two tables table1 and table2

table1 has the columns:

id name  value
1  name1 0.5
2  name2 1.9
3  name3 2.6
4  name4 0.2
....
999 name999 4.7

table2 has the columns

id risk   value
1  low    0.5
2  medium 1.5
3  high   2.5

I want to create a result for example: (low >=0.5 and <1.5 , medium >=1.5 and <2.5, high >2.5) and from higher value to smaller value

1  name999 high
2  name3 high
3  name2 medium
4  name1 low

Addition

Another one question:

table1 has the columns:

id name  value
1  name1 0.5
2  name2 1.9
3  name3 2.6
4  name4 0.2
....
999 name999 4.7

suppose in column name we have test1 and test2 and we want in the result for test1 to always be very low and for test2 very high.So what will be the sql modification to have this result?

1  test2   very high
2  name999 high
3  name3 high
4  name2 medium
5  name1 low
6  test1 very low

do we have to edit table2 also for ordering the above result by risk?

  • 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-05-25T03:06:59+00:00Added an answer on May 25, 2026 at 3:06 am
    SELECT a,id
         , a.name
         , b.risk 
    FROM table1 AS a
      JOIN table2 AS b
        ON b.value = ( SELECT MAX(bm.value)
                       FROM table2 AS bm
                       WHERE bm.value <= a.value
                     )
    ORDER BY a.value DESC
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two tables: table1, table2. Table1 has 10 columns, table2 has 2 columns.
I have two tables; Leads, Territories and Referrers. Lead has columns: ID, Name, TerritoryId
I have an excel file which has two columns (1. Name and 2. Value)
I have two tables named foo and bar , hypothetically speaking. foo has columns
I have two tables: a 'userlist' that has a 'grade' and 'userID' columns, and
I have two tables, Band and Votes. Band has a name and an id,
I have two tables like : Docs {#DocId, SomeData} KeyValues {#RowId, DocId, Name, Value}
I have a table companies , which has two columns named name and address
I have two tables TableA and TableB. Now TableA has 2 columns: ID &
If I have two tables A and B, so that table A has columns:

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.