• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 478
  • Last Modified:

SQL Query - combining two ISNULL and IF Statements

Hi Experts!

Hows it going!

I have two sql query statements which work perfectly, what I want to do is combine these two queries so the results appear in one column.

These are the statements:

ISNULL(CASE WHEN [Box] = 'RS' AND Reject = 1 THEN 'RR' ELSE [Box] END, Containers) AS Something2


ISNULL(CASE WHEN [Box] = 'PS' AND Reject = 1 THEN 'PR' ELSE [Box] END, Containers) AS Something3

Can you please tell how I can combine the above two queries into one query.

Many thanks

Kesh
0
J3D1-KN1G1-1t
Asked:
J3D1-KN1G1-1t
  • 2
1 Solution
 
Lee SavidgeCommented:
Does this work for you?

CASE
    WHEN isnull(Box, containers) = 'RS' AND Reject = 1 THEN 'RR'
    WHEN isnull(Box, containers) = 'PS' AND Reject = 1 THEN 'PR'
    ELSE isnull(Box, containers)
END AS Something
0
 
J3D1-KN1G1-1tAuthor Commented:
Below worked for me, thanks for your inspiration.


ISNULL(CASE WHEN [Box] = 'RS' AND Reject = 1 THEN 'RR'
                     WHEN [Box] = 'PS' AND Reject = 1 THEN 'PR'
             ELSE [Box] END, containers) AS Recycle_Code4

Many Thanks Mate
0
 
Lee SavidgeCommented:
No problem. Glad to help :)
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now