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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T08:28:06+00:00 2026-06-11T08:28:06+00:00

I believe a Group By would solve the following, but maybe it’s Select Distinct.

  • 0

I believe a Group By would solve the following, but maybe it’s Select Distinct. Either way, I respectfully turn to you:

The Goal:

To consolidate by Agreement then LaborCode then Schedule. I work for a company that performs multiple services and I want to take any range of dates and specify what DAYS OF THE WEEK we perform each service. Over the period of a month we would have (4) Mondays – I want to just see ONE Monday. As a side note, I have tried XML Path but it doesn’t seem to work.

The Code:

Select Top 100 Percent Agreements.AgrmntID, JobSites.SiteName,
  Customers.CompanyName, LaborCodeTypes.Description As LaborCode, DateName(dw,
  AgreementSchedules.SchedDate) as Schedule
From Agreements Inner Join
  AgreementSchedules On Agreements.AgrmntID = AgreementSchedules.AgrmntID
  Inner Join
  Customers On Agreements.CustID = Customers.CustID Inner Join
  JobSites On Agreements.CustSiteID = JobSites.CustSiteID Left Outer Join
  LaborCodeTypes On AgreementSchedules.RepairID = LaborCodeTypes.RepairID
Where Agreements.Status = 2

The Data (Schedule is derived from AgreementSchedules.SchedDate) – 2 weeks selected:

AgrmntID    SiteName   Company   LaborCode    Schedule
---------- ---------- ---------- ---------- ----------
1           JOB01      COMP01    Sweeping     Monday
1           JOB01      COMP01    Sweeping     Wednesday
1           JOB01      COMP01    Sweeping     Monday
1           JOB01      COMP01    Sweeping     Wednesday
1           JOB01      COMP01    Porter       Thursday
1           JOB01      COMP01    Porter       Thursday
2           JOB02      COMP02    Landscaping  Tuesday
2           JOB02      COMP02    Landscaping  Tuesday

The Desired Output:

AgrmntID    SiteName   Company   LaborCode    Schedule
---------- ---------- ---------- ---------- ----------
1           JOB01      COMP01    Sweeping     Monday
1           JOB01      COMP01    Sweeping     Wednesday
1           JOB01      COMP01    Porter       Thursday
2           JOB02      COMP02    Landscaping  Tuesday

Thank you SO much in advance. I’ve been trying to figure this out for days with no luck.

  • 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-11T08:28:08+00:00Added an answer on June 11, 2026 at 8:28 am

    Either would work.

    I’d go for DISTINCT

    Select DISTINCT Agreements.AgrmntID, JobSites.SiteName, 
      Customers.CompanyName, LaborCodeTypes......
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to figure out how I would setup a group of images
I have the following query: SELECT location, step, COUNT(*), AVG(foo), YEAR(start), MONTH(start), DAY(start) FROM
Why would the following query return Error converting data type varchar to bigint? Doesn't
I believe that the question Is there a good way to do this type
This is for Drupal 6. Field display weights (per node) would solve this problem
So I've been running through all the questions under the greatest-n-per-group tag, and either
The following TSQL provides an example of how I might solve this problem with
I know this sounds backwards but I am looking for a way to search
I'm aware of several question on this forum relating to this. But I'm not
group box, flow layout panel, panel, split container,and tab control do not drag. I

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.