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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T08:03:04+00:00 2026-06-06T08:03:04+00:00

i have two tables i am trying to get information from. login table –

  • 0

i have two tables i am trying to get information from.

login table – which has the list of employees

projects table – which has the projects

in short, i am trying to write a query that will select the copywriters and perform a subquery on each that will return a field dubbed ‘open_projects’. This, i can get to work with the below sql:

select web_login_id,
                (select count(project_web_id) from project
                where copywriter = web_login_id
                and (`status` = 'open' or `status` = 'qual')) as open_projects from login
                where roles like '%copywriter%'
                and tierLevel like '%c1%'
                order by open_projects asc

This returns something like:

1982983 3

1982690 22

2987398 5

The problem with this is that sometimes 5 or 6 of the projects will belong to the same client and are not actually being worked on as they are dealt with in a queue-ish fashion.

My question is how to modify the above sql so that the subquery will GROUP subset based on the client_login_id field.

This sql gives me an error of : subquery returns more than 1 row

select web_login_id,
                (select count(project_web_id) from project
                where copywriter = web_login_id
                and (`status` = 'open' or `status` = 'qual') group by client_login_id) as open_projects from login
                where roles like '%copywriter%'
                and tierLevel like '%c1%'
                order by open_projects asc
  • 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-06T08:03:05+00:00Added an answer on June 6, 2026 at 8:03 am

    You need to rephrase this as an explicit join. I think the following does the trick:

    select web_login_id, cw.open_projects
    from login l left outer join
          (select copywriter, count(project_web_id) as open_projects
           from project
           where `status`  in ('open', 'qual')
           group by copywriter
          ) cw
          on l.web_login_id = cw.copywriter
    where l.roles like '%copywriter%' and l.tierLevel like '%c1%' 
    order by open_projects asc 
    

    I’m not sure what the “group by client_login_id” is doing. It doesn’t seem necessary.

    Once you’ve done this, you can return as many columns as you like from the subquery.

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

Sidebar

Related Questions

I have two tables: hotels and hotel_rooms I'm trying to get a table with
I have two tables containing product information, and product variations. I’m trying to list
I have two tables and I am trying to get information with an outer
I have a projects table which has two foreign keys for users (user_id and
I have two tables: events_archive and reports. The events table shows all information about
I have a two tables. One has manufacturer information and includes the regions where
I have two tables: subject and student. I'm trying to count the number of
I am trying to develop an application using ADO.NET. I have two tables in
I'm having some problems trying to perform a query. I have two tables, one
For Android I have two labels in a table row. I am trying to

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.