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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:57:11+00:00 2026-06-14T03:57:11+00:00

I am having an issue getting the results I want from my SQL statement.

  • 0

I am having an issue getting the results I want from my SQL statement. I know I’m probably missing something simple but I just can’t see it.

Here are my tables.

Table: Users (RoleID is linked to ID in Roles Table)
ID,   FirstName,   LastName,   RoleID 
1,    Matt,        Ryan,       1
2,    Chipper,     Jones,      1
3,    Julio,       Jones,      2
4,    Jason,       Bourn,      3

Table: Roles
ID,    Name
1,     Field Rep
2,     Tech
3,     Admin

Table: FRrequests (UserID is linked to ID in Users table) 
ID,   UserID,    Status
1,    1,         Open
2,    1,         Submitted
3,    1,         Delayed
4,    1,         Complete

What I want is an SQL statement that shows me a count of all the “Submitted” & “Delayed” requests for all the Field Reps. Below is an example of desired results.

Name             Count
Chipper Jones    0
Matt Ryan        2

Here is the statement I have so far and the results it gives me.

SELECT Users.FirstName + ' ' + Users.LastName AS Name, COUNT(FRrequests.ID) AS 'Open Requests'
FROM Users INNER JOIN
          Roles ON Users.RoleID = Roles.ID LEFT OUTER JOIN
          FRrequests ON Users.ID = FRrequests.UserID
WHERE (Roles.Name = N'Field Rep') AND (FRrequests.Status = 'Submitted' OR FRrequests.Status = 'Delayed')
GROUP BY Users.FirstName, Users.LastName

Name             Count
Matt Ryan        2

I know that the “AND (FRrequests.Status = ‘Submitted’ OR FRrequests.Status = ‘Delayed’)” part is what is breaking it. If I run it without that in the statement I get all the users but it counts all status not just submitted and delayed. I just can’t figure out what I’m missing to get this to work. Any help would be greatly appreciated.

  • 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-14T03:57:13+00:00Added an answer on June 14, 2026 at 3:57 am

    You are really close, try the following:

    SELECT U.FirstName + ' ' + U.LastName AS Name, COUNT(F.ID) AS 'Open Requests'
    FROM Users U
    INNER JOIN Roles R
        ON U.RoleID = R.ID 
    LEFT JOIN ( SELECT * FROM FRrequests 
                WHERE Status IN ('Submitted','Delayed')) F
        ON U.ID = F.UserID
    WHERE R.Name = N'Field Rep' 
    GROUP BY U.FirstName, U.LastName
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm having an issue with outputting results from a list into strings and getting
I'm having an issue getting a COUNT() from a SQL query using Zend_Db_Table_Select, and
I'm having an issue getting the correct value from my drop down box. Basically
I'm having a little problem getting SQL Server returning the same results as Oracle
My goal sounds fairly simple, at the moment i'm having an issue getting my
I'm having an issue getting a LINQ query to work. I have this XML:
I'm having an issue getting some code to work. Is there a way to
I'm having an issue getting files loaded into an app called GCS, by dragging
I'm having an issue getting this CSS for a sprite sheet to work on
I'm having an issue getting Appstats to work correctly. Using /appstats or /appstats/stats ends

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.