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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:38:33+00:00 2026-05-26T18:38:33+00:00

I have a table A. |—-+—-| | P | S | |—-+—-| | p1

  • 0

I have a table A.

|----+----|
| P  |  S |
|----+----|
| p1 |  1 |
| p2 |  7 |
| p3 | 14 |
| p4 | 23 |
| p5 |  1 |
|----+----|

and table B

|----+----|
|  S |  C |
|----+----|
|  1 | 21 |
|  5 | 21 |
| 23 | 21 |
|  1 | 30 |
|  7 | 90 |
|----+----|

I need to sort table A.

Sorting order:

A. TableA.S exists where  (TableA.S = TableB.S) and TableB.C = 21
B. TableA.P

Final Output:

|----+----|
| P  |  S |
|----+----|
| p1 |  1 |
| p4 | 23 |
| p5 |  1 |
| p2 |  7 |
| p3 | 14 |
|----+----|

This needs to be converted to DBIx::Class query.

I tried following:

Select tableA.P, tableA.S
from tableA left join tableB on tableA.S = tableB.S
where (tableB.C = 21 or tableB.C is NULL)
order by tableB.C, tableA.P

But I am missing somewhere to get the result where tableB.S is ‘7’.

Thanks.

  • 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-26T18:38:33+00:00Added an answer on May 26, 2026 at 6:38 pm

    This sorts by A.P for all the records in A a matching record is found in B then by A.P for the other records.

     SQL> select A.P
           , A.S
    from A 
         left join B        
            on ( A.S = B.S 
                 and B.C = 21)
    order by nvl2(B.S, 'ZZZZZZZZZZ', A.P), A.P
    /
    
      2    3    4    5    6    7    8  
    P           S
    -- ----------
    p1          1
    p4         23
    p5          1
    p2          7
    p3         14
    
    SQL>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have table with some fields that the value will be 1 0. This
I have table A in Oracle that has a primary key (id). I need
I have table like this create table tbl_1( year int, month int, day int
I have table with two SelectOneMenu in row. I need populate data in second
I have table sort of like Name |DateOfEvent|EventType ---------------------------------- Smith |10/1/2005 |New Thomas |1/1/2002
I have table ,and i need access them from shell script and do the
I have table named highscore like this: nameQL scoreQL piotr 50 And flash game
I have table project, screenshot, sub_screenshot, and user I want to achieve this kind
I have table that doesn't need a specific field to be the primary key.
I have table that has two columns and I need to concatenate these two

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.