how to remove or condition in my query

Hi Experts,

how to remove or condition in the below query:

SELECT IF(w.task_status ='TASK-NOTCOMP' AND t.success IS NULL OR (w.task_status = 'TASK-ACT-IDLE' AND t.action_status='TASK-ACT-IDLE' AND UNIX_TIMESTAMP(t.scheduled_time) < UNIX_TIMESTAMP(NOW())+600 ), 'PHYSICAL', 'LOGICAL') as output, t.workaction_id, w.task_status,w.task_id  FROM workaction as t INNER JOIN work as w ON (t.task_id=w.task_id) WHERE (t.task_id IN (423934))

the above query

if condition A OR condition B   --->PHYSICAL,LOGICAL
IF both conditons true -->PHYSICAL
IF FALSE---->LOGICAL

Because of or condition i am unable to convert  this sql query to Hibernat hql query
is there any alternative query for this ?
how to remove or condition?

Thanks
LVL 2
srikoteshAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Rgonzo1971Commented:
Hi,

maybe

case A and B then PHYSICAL else case A then PHYSICAL,LOGICAL else case B then PHYSICAL,LOGICAL else LOGICAL end end end

Regards
0
Walter RitzelSenior Software EngineerCommented:
Try this:
select case 
           when (w.task_status ='TASK-NOTCOMP' AND t.success IS NULL) and (w.task_status = 'TASK-ACT-IDLE' AND t.action_status='TASK-ACT-IDLE' AND UNIX_TIMESTAMP(t.scheduled_time) < UNIX_TIMESTAMP(NOW())+600 ) then 'PHYSICAL' 
           when (w.task_status ='TASK-NOTCOMP' AND t.success IS NULL) then PHYSICAL,LOGICAL 
           when (w.task_status = 'TASK-ACT-IDLE' AND t.action_status='TASK-ACT-IDLE' AND UNIX_TIMESTAMP(t.scheduled_time) < UNIX_TIMESTAMP(NOW())+600 ) then 'PHYSICAL,LOGICAL'
           else 'LOGICAL' end  as output, t.workaction_id, w.task_status,w.task_id  FROM workaction as t INNER JOIN work as w ON (t.task_id=w.task_id) WHERE (t.task_id IN (423934))

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
srikoteshAuthor Commented:
Hi Experts,
The above query is working fine.
case A and B  true then physical
case A  true then physical ,logical  //i did not understand this point because if case A is true then phyiscal why we need to place logical as well in this line
case B true then physical,logical  else logical end

shall i do like this

case A and B true then physical
case A true then physical
case B true then physical
esle logical end.

if this is not correct
explain the scenario bit clarity.
0
Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

Walter RitzelSenior Software EngineerCommented:
The above assumes that you are delivering strings, as you have requested. If Physical and Logical are not strings, then you should explain that and we can change the query.

Your definition:
if condition A OR condition B   --->PHYSICAL,LOGICAL
IF both conditons true -->PHYSICAL
IF FALSE---->LOGICAL
0
srikoteshAuthor Commented:
those are strings only

condition A OR B true PHYSICAL,LOGICAL

the above condition  to remove or condition alternative way is the below one.
can you please verify it. if this is correct or not

if condition A true -->physical
if condition B true-->physical
IF both conditons true -->PHYSICAL
else (A and B FALSE)---->LOGICAL
0
Walter RitzelSenior Software EngineerCommented:
No, your logic is not correct. Because the only way to get logical is if both conditions are FALSE.
The OR in your original code does not do that.
The code I have provided is correct according to your original request.

You cannot have pieces of the string returned on different logic expressions in a SQL.
Thus you need to return both values in the same case.

Use the code I have provided.
0
srikoteshAuthor Commented:
First time i got the hibernate hql query solution in expets exchange.

Excellent
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
MySQL Server

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.