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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T09:37:45+00:00 2026-06-17T09:37:45+00:00

I have 2 tables: AppDetailFee table has AppID (PK), TypeID, Amount AppDetail table has

  • 0

I have 2 tables:

AppDetailFee table has AppID (PK), TypeID, Amount
AppDetail table has AppID (PK)   

I join both tables on AppID and I need to check the following for TypeID and amount. There are 3 scenarios:

If TypeID = 6 and Amount = 0 then  print appid and amount zero
If typeID = 6 and amount <> 0  - bypass and do not print
When TypeID <> 6 then print zero

Below is the code that I used, btu I get a result of all the rows that are not equal to zero with an amount of zero.

Any help would be appreciated.
Thanks

SELECT  ad.AppID
      , MAX(case when (adf.TypeID = 6 AND adf.Amount = 0) then 0 
                 when (adf.TypeID = 6 AND adf.Amount <> 0) then Adf.Amount
       ELSE 0 END) AS FeeAmount

FROM         
      AppDetail AS ad   

inner join  AppDetailFee adf ON
      ad.AppID = adf.AppID 

WHERE  adf.Amount =0
  • 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-17T09:37:46+00:00Added an answer on June 17, 2026 at 9:37 am

    You have a WHERE clause that is removing everything that does not meet the criteria:

    WHERE  adf.Amount =0
    

    Try removing that and running your query:

    SELECT  ad.AppID
          , MAX(case when (adf.TypeID = 6 AND adf.Amount = 0) then 0 
                     when (adf.TypeID = 6 AND adf.Amount <> 0) then Adf.Amount
                     else 0 END) AS FeeAmount
    FROM  AppDetail AS ad   
    inner join  AppDetailFee adf ON
          ad.AppID = adf.AppID 
    group by ad.AppID
    

    You are also missing the GROUP BY clause on your query.

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

Sidebar

Related Questions

I have tables item and store (it's a store management system). item table has
I have tables with following structure: -- Table structure for table `temp_app` -- CREATE
I have tables Member and Transaction . Table Member has 2 columns MemberID and
I have tables like Person{id, name, dob} employee{id, company_name, joining_date}. I need to join
I have tables linked by FK, I query on the first table using entity
Suppose I have tables: Employee(empid, ....) Phone(phoneid, ...) EmployeePhone(empid, phoneid, ...) there is foreign
have tables like this Table checklist idCardno name permAddress datetime Table persons name idcardno
I have tables foo and bar: create table foo(a int, b varchar(10), primary key
I have tables & data like this: venues table contains : id +----+---------+ |
I have tables of data samples, with a timestamp and some data. Each table

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.