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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T23:29:27+00:00 2026-06-15T23:29:27+00:00

I am running SQL 2008, I have been tasked to create a report that

  • 0

I am running SQL 2008, I have been tasked to create a report that groups ‘vendor name’ and certain information together, furthermore group it by fiscal year and their quarters.

It went well up the the grouping by year, except that our fiscal start isnt on January but instead November. I have a date field called ‘Expected Arrival Date’ that is formatted as ‘yyyy-mm-dd hh:mm;ss.mmm’ I am not sure how i can group it to associate:

A. the fiscal year starting with November year before to the rest of the fiscal year ending at October (example fiscal year 2012 = beginning November 2011 – End October 2012

B. The fiscal quarter Nov1- Jan31 , Feb1 – Apr30, May1-July31, Aug1-Oct31

Here is the code I already have

SELECT 
    YEAR([Expected Arrival Date])as 'Year',
    MONTH([Expected Arrival Date]) as 'Month',
    [Vendor Name], 
    (SUM(CASE WHEN ([Days Past Due] = 0) THEN [Qty Received] ELSE 0 END) / SUM([Qty Received])) * 100  AS 'On-Time %',
    (SUM(CASE WHEN ([Days Past Due] < 0) THEN [Qty Received] ELSE 0 END) / SUM([Qty Received])) * 100  AS 'Early %',
    (SUM(CASE WHEN ([Days Past Due] > 0) THEN [Qty Received] ELSE 0 END) / SUM([Qty Received])) * 100  AS 'Late %',
    SUM([Qty Received]) aS 'TOTAL'

FROM data_view 
GROUP BY YEAR([Expected Arrival Date]),MONTH([Expected Arrival Date]),[Vendor Name]
ORDER by YEAR([Expected Arrival Date]),MONTH([Expected Arrival Date])

If you have any helpful pointers to create a nice query it would also be appreciated.

Edit**
The structure of the data_view is as follows

    SELECT        [Receipt #], [Vendor Code], [Vendor Name], [PO Applied], [PO Line #], [Item Code], [Item Description], [Expected Arrival Date], [Receiving Date], [Receiving Date Filter], 
                         [Qty Received], [Qty Ordered], [% Received], [PO Date], [Receipt User], DATEDIFF(dd, CAST(CAST([Expected Arrival Date] AS CHAR) AS DATETIME), 
                         CAST(CAST([Receiving Date] AS CHAR) AS DATETIME)) AS [Days Past Due]
FROM            (SELECT        T1.RCPNUMBER AS [Receipt #], T1.VDCODE AS [Vendor Code], T1.VDNAME AS [Vendor Name], T4.PONUMBER AS [PO Applied], 
                                                    T3.DETAILNUM AS [PO Line #], T2.ITEMNO AS [Item Code], T2.ITEMDESC AS [Item Description], 
                                                    CASE WHEN T3.EXPARRIVAL = 0 THEN CASE WHEN T4.EXPARRIVAL = 0 THEN CAST(CAST(T4.DATE AS CHAR) AS DATETIME) 
                                                    ELSE CAST(CAST(T4.EXPARRIVAL AS CHAR) AS DATETIME) END ELSE CAST(CAST(T3.EXPARRIVAL AS CHAR) AS DATETIME) 
                                                    END AS [Expected Arrival Date], CAST(CAST(T1.DATE AS CHAR) AS DATETIME) AS [Receiving Date], CAST(CAST(T1.DATE AS CHAR) AS DATETIME) 
                                                    AS [Receiving Date Filter], T2.RQRECEIVED AS [Qty Received], T3.OQORDERED AS [Qty Ordered], 
                                                    ROUND(CASE WHEN T2.OQORDERED <> 0 THEN (T2.RQRECEIVED / T2.OQORDERED) * 100 ELSE 100 END, 2) AS [% Received], 
                                                    CAST(CAST(T4.DATE AS CHAR) AS DATETIME) AS [PO Date], T5.ENTEREDBY AS [Receipt User]
                          FROM            canada.dbo.PORCPH1 AS T1 INNER JOIN
                                                    canada.dbo.PORCPH2 AS T5 ON T1.RCPHSEQ = T5.RCPHSEQ INNER JOIN
                                                    canada.dbo.PORCPL AS T2 ON T2.RCPHSEQ = T1.RCPHSEQ INNER JOIN
                                                    canada.dbo.POPORL AS T3 ON T3.PORHSEQ = T2.PORHSEQ AND T3.PORLSEQ = T2.PORLSEQ INNER JOIN
                                                    canada.dbo.POPORH1 AS T4 ON T4.PORHSEQ = T3.PORHSEQ) AS tblReceips
  • 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-15T23:29:27+00:00Added an answer on June 15, 2026 at 11:29 pm

    Something like this should work:

    SELECT 
        YEAR([Expected Arrival Date]) + CASE
            WHEN MONTH([Expected Arrival Date]) IN (11, 12) THEN 1
            ELSE 0
        END As FiscalYear,
        CASE
            WHEN MONTH([Expected Arrival Date]) IN (11, 12, 1) THEN 1
            WHEN MONTH([Expected Arrival Date]) IN (2, 3, 4) THEN 2
            WHEN MONTH([Expected Arrival Date]) IN (5, 6, 7) THEN 3
            ELSE 4
        END As FiscalQuarter,
        ...
    GROUP BY
        YEAR([Expected Arrival Date]) + CASE
            WHEN MONTH([Expected Arrival Date]) IN (11, 12) THEN 1
            ELSE 0
        END,
        CASE
            WHEN MONTH([Expected Arrival Date]) IN (11, 12, 1) THEN 1
            WHEN MONTH([Expected Arrival Date]) IN (2, 3, 4) THEN 2
            WHEN MONTH([Expected Arrival Date]) IN (5, 6, 7) THEN 3
            ELSE 4
        END,
        [Vendor Name]
    ORDER BY
        FiscalYear,
        FiscalQuarter
    ;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

On Sql Server 2008, I have a slow-running update query that has been working
Running SQL Server 2008 (not R2). I have a few reports that have URLs
I have a view defined in SQL server 2008 that joins 4 tables together.
I'm running Visual Studio 2008 and have been told that I have all rights
I have a SQL 2008 R2 Express database that Im running an ASP.NET MVC
I have a SQL Server 2008 R2 Report Server running on a Windows 7
We have a single computer with Windows7 Home Premium running with SQL Server 2008
Please help this beginner here... I have a SQL Server 2008 R2 running on
I have a sql server on a dedicated machine, running SQL 2008. I have
I have been using windows XP. I installed visual studio 2008 and sql server

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.