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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T10:49:32+00:00 2026-06-14T10:49:32+00:00

I want to retrieve the columns from the table., depending on the conditions., what

  • 0

I want to retrieve the columns from the table., depending on the conditions.,
what I can use.

For example, I’ ve fields namely, add order comments, cancel order comments, postpone order comments, action(add, cancel, postpone) and amount received(Y/N)

Now I’ve to fetch columns add order comments, cancel order comments, postpone order comments depending on action and amount received.,

if(action='add' and amount received='Y')
then
i've to fetch add order comments column
elseif(action='postpone' and amount received='Y')
then
i've to fetch postpone order comments column
else (action='cancel')
then i've to fetch cancel order comments

how to get this done in sql or plsql., I want this conditions in select statement

  • 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-14T10:49:33+00:00Added an answer on June 14, 2026 at 10:49 am

    Note that by “sql or plsql” I’m assuming that “sql” refers to T-SQL as used by MS SQL Server. If not, please use the appropriate equivalent in your language.

    You need to use a CASE (T-SQL) statement (PL-SQL equivalent)

    For example, in T-SQL:

    SELECT OrderId AS OrderId
           CASE 
               WHEN Action = 'add' AND amountRcd = 'Y' THEN addOrderComment
               WHEN Action = 'postpont' AND amountRcd = 'Y' THEN postponeOrderComment
               WHEN Action = 'cancel' THEN cancelOrderComment 
               ELSE 'Unrecognised action'
           END AS Comment
    FROM tblOrders
    

    Note also that in the rules you’ve given, if the amountRcd field is not Y, then you will get “Unrecognised action” as the comment. I think you may need to clarify your rules to prevent this.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to retrieve data from 2 columns of my database table and bind
I have a HTML table as follows. I want retrieve row values from this
I want to retrieve the java data types of the columns of a table
I have table employee I retrieve the columns as select emp_name,emp_add from employee while(iResultSet1.next())
I need to retrieve all rows from a table where 2 columns combined are
I want to select two columns from the table so is it possible to
I want to retrieve website title from webview cookies of my application. I am
I have a DB consisting of 4 fields.My application will retrieve data from that
I have the following table and I want to retrieve students ( STUD_ID )
I need to retrieve a list of the columns in a table in the

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.