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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T20:57:37+00:00 2026-06-12T20:57:37+00:00

My table user_name id status calls =========================================== apple 21 BadAd 2 apple 21 Lead

  • 0

My table

user_name     id      status          calls
===========================================
apple        21       BadAd             2
apple        21       Lead              5
apple        21       DNC               6
apple        21       pajs              2
orange       34       Lead              9
orange       34       disks             3
orange       34       BadAd             8
orange       34       pajs              5

My attempt

 SELECT sum(calls) FROM (SELECT y.calls, y.user_name, y.status FROM stats
 INNER JOIN
 (select user_name, status, sum(calls) as calls
 from stats WHERE status = ('BadAD', 'Lead', 'DNC')
 group by user_name, status) y
 ON y.user_name = stats.user_name
 GROUP BY y.status) w WHERE w.user_name = y.username

My problem: I am trying to add up the values from the calls field of rows that only contain a certain status field value (WHERE status = ('BadAD', 'Lead', 'DNC')) and has the same user_name. So it would look like this.

user_name     id      status          calls
===========================================
apple        21       BadAd             13           (BadAd 2 + Lead 5 + DNC 6)
orange       34       Lead              17           (etc..)
  • 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-12T20:57:38+00:00Added an answer on June 12, 2026 at 8:57 pm
    select user_name, id, min(status), sum (calls)
    from yourtable
    where status in  ('BadAD', 'Lead', 'DNC')
    group by user_name, id
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a table user_name id status calls =========================================== apple 21 cars 67 apple
I have a little problem in updating date. My first table is DONOR donor-nic----username-----status
I've a table with entities: reg_num, user_name, phone_num, designation I want to write stored
I want to retrieve the email address from the table and using that to
I need to update existing users IsApproved status in the aspnet_Membership table. I have
I am looking for the best approach to delete records from a table. For
I try this query from Oracle : select * from a_table@Postgres; Here is the
this is the event table that records all the status(IN/OUT): +--------------------------------------------------+-----------------+ | Event_ID |
I have the following Query: SELECT a.name_f, a.uid, a.name_l, a.profile_pic, b.position FROM users a
I have two tables: Users: ID, first_name, last_name Networks: user_id, friend_id, status I want

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.