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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T13:45:00+00:00 2026-06-06T13:45:00+00:00

Here is my situation. I need to create a report that shows each open

  • 0

Here is my situation. I need to create a report that shows each open work order and that also shows the last labor date, if there is one, and the number of elapsed days since the last labor date. Here is a representation of the SQL that created the dataset:

select segments.date_created,
       headers.order_number
       segments.segment_id
       lines.line_type
       lines.line_qty * lines.unit_price line_amt,
       case when lines.line_type = 3
         then max(clocking.clock_date)
         else convert(date, '1900-01-01')
         end last_clock_date,
       case when lines.line_type = 3
         then datediff(day, max(clocking.clock_date), getdate())
         else datediff(day, convert(date, '1900-01-01'), getdate())
         end DALL
from segments inner join headers on segments.header_id = headers.header_id
              left join lines on header.header_id = lines.header_id
              left join clocking on header.header_id = clocking.header_id and 
                                    segments.segment_id = clocking.segment_id and
                                    lines.line_id = clocking.line_id
where headers.status = 0
and segments.branch = @branch
and headers.folder_id in ('400', '401')
and headers.order_number not like 'WP%'
group by headers.order_number, segments.segment_id,
         lines.line_type, segments.date_created, lines.line_qty,
         lines.unit_price

Sample output is:

    date_created  order_number  segment_id  line_type  line_amt  clock_date  DALL
    2012-05-10    HA025050      1           1          288.58     1900-01-01  41072
    2012-05-10    HA025050      1           3          81.00      2012-05-10  35
    2012-05-10    HA025050      2           1          22.90      1900-01-01  41072
    2012-04-26    W7184315      1           3          1062.50    2012-05-08  37
    2012-04-26    W7184315      1           1          69.68      1900-01-01  41072
    2012-04-26    W7184315      1           1          61.96      1900-01-01  41072
    2012-04-27    W7184357      1           1          682.11     1900-01-01  41072

Two things to note, I am jamming the date 1900-01-01 into clock_date for all lines that are not labor lines ie: not line 3. In my report I am grouping by order_number and segment_id.

Report output needs to be:

    order_number  segment_id  amount    date_created  clock_date  DALL
    HA025050      1           369.58    2012-05-10    2012-05-10  35
    HA025050      2            22.90    2012-05-10                 0
    W7184315      1          1194.14    2012-04-26    2012-05-08  37
    W7184357      1           682.11    2012-04-27                 0

           Count: 4    Total: 2268.73                       Days: 72      Avg:  18

Report output is:

    order_number  segment_id  amount    date_created  clock_date  DALL
    HA025050      1           369.58    2012-05-10    2012-05-10  35
    HA025050      2            22.90    2012-05-10                 0
    W7184315      1          1194.14    2012-04-26    2012-05-08  37
    W7184357      1           682.11    2012-04-27                 0

           Count: 4    Total: 2268.73                   Days:  205432     Avg:  51358

Since each line of the dataset is an order line the order total amount sums correctly, however the report is summing all of the lines of the dataset for the total DALL value, which is incorrect. I want to sum just the DALL values that appear in the report. In the expression for the DALL field I am inserting a “0” if the clock_date = ‘1900-01-01’. I need all of the lines because the service manager wants all work orders whether there is labor on it or not, and he wants those orders represented as 0 DALL. I have already had the conversation with him about how that will skew his results, apparently he likes skewed results. I think I have given enough information, if you need to know anything else let me know.

  • 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-06T13:45:01+00:00Added an answer on June 6, 2026 at 1:45 pm

    I figured it out a while back, just been too busy to place it here. I thought since there was not really a way to do it in SSRS, I went to the SQL. Instead of placing 1900-01-01 in the labor_date field I allowed SQL to place a null. Now when it adds everything up the nulls get ignored.

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

Sidebar

Related Questions

I have a situation, where I need to create a new JavaScript object that
I have a situation here. I need to create an employee card structure in
The situation is, that i need to create table in grid view looking like
Here's my situation: I'm trying to create a SSL certificate that will be installed
Here's the situation: I need to create a game for an interactive kiosk. The
Here's the situation: I've got a class that is doing too much. It's mainly
Here's the situation. Due to the design of the database I have to work
I have a situation where i need to create a left panel. My manager
So here is my situation, and the solution that I've come up with to
Here is the situation: the company that I'm working in right now gave me

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.