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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T03:55:53+00:00 2026-05-18T03:55:53+00:00

i spent around 4 hours on this but i couldnt find answer, i want

  • 0

i spent around 4 hours on this but i couldnt find answer, i want the result like

Rejects

somefilename1.txt – Rejected (and if no file then No from else expression(No – Invalid) – Query 1)
somefilename2.txt – Previous (and if no file then No from else expression(No – Valid) -Query 2)

I dont understand what do i do, do i use union all or case expression. plz help me with this.

QUERY1:

if exists (select NULL from table1 where Column1 = 'File1')
    select distinct Column1 +'-'+ 'Rejected' as 'Rejects' from table1
    where Column1 = 'File1'
else 
    select 'No' as 'Invalid'

QUERY2:

if exists (select NULL from table1 where Column1 = 'File2')
    select distinct Column1 +'-'+ 'Previous' as 'Rejects' from table1
    where column1 = 'File2'
else 
    select 'No' as 'valid'

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-18T03:55:54+00:00Added an answer on May 18, 2026 at 3:55 am

    Base on comments, see if this returns what you’re looking for.

    If there are no records in the table the result is No Input File

    When records are present, each row is evaluated with the CASE statement.

    --drop table table1
    
    create table table1
    (SubjectArea varchar(255)
    , SrcFileName varchar(255))
    
    insert into table1
    select 'UaqaFacetsPvs','somefilename1.txt'
    union select 'UaqaFacetsRjct','somefilename2.txt'
    union select null,null
    union select null,'somefilename2.txt'
    
    IF EXISTS(SELECT NULL FROM table1 WHERE SubjectArea in ('UaqaFacetsRjct','UaqaFacetsPvs'))
        SELECT DISTINCT SrcFileName
         + ' - ' + 
         CASE SubjectArea 
            WHEN 'UaqaFacetsPvs' THEN 'FacetsPvsFile'
            WHEN 'UaqaFacetsRjct' THEN 'FacetsRjctFile'
            ELSE ''
          END AS Result
        FROM table1
        WHERE SubjectArea in ('UaqaFacetsRjct','UaqaFacetsPvs')
    ELSE SELECT 'No input file' AS Result
    

    This IF returns this:

    Result
    ---------------------------------
    somefilename1.txt - FacetsPvsFile
    somefilename2.txt - FacetsRjctFile
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I just spent a few hours looking around here but didn't really find a
I've spent a couple hours trying to find a good answer to this.. How
I would not say I wasted my time, but spent around few hours changing
I would not say I wasted my time, but spent around few hours changing
I've spent a few hours playing around with this one, without success so far.
I've spent the last few hours trying to find the solution to this question
I spent around two hours on that problem, and I have visited these stackoverflow
I spent some time looking around, and all I could find is Jython. It's
Spent a good few hours on this now and don't seem to be getting
So I've spent around 5 or 6 hours today battling with Symfony2 forms and

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.