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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T13:33:50+00:00 2026-06-10T13:33:50+00:00

I have this data that shows consolidated report grouped by year. What I have

  • 0

I have this data that shows consolidated report grouped by year. What I have used is a simple
GROUP BY YEAR(BookingDate) clause and everything works fine. But what I want is the year to be financial year (1 April to 31 May) and not the normal calender year, so how can I do this? The query is..

SELECT 
    CONVERT(VARCHAR(25), c.Duration) AS Duration, 
    COALESCE(c.totalbookings, 0) AS totalbookings
FROM
    (SELECT 
               YEAR(bookingdate) AS Duration, 
               COUNT(*) AS totalbookings 
           FROM 
               entbookings
            WHERE BranchId=@Branchid
           GROUP BY YEAR(bookingdate)
    ) AS c 
LEFT OUTER JOIN 
    (SELECT 
               Duration, 
               SUM(totalitems) 'bkdqty'
           FROM 
               [yrItemWISeTotalQty] (@BranchId) AS BkdQty
           GROUP BY Duration
    ) AS d 
ON c.Duration = d.Duration

The yrItemWISeTotalQty is defined as

CREATE FUNCTION [dbo].[yrItemWiseTotalQty]
(
@BrachId VARCHAR(MAX)
) 

RETURNS TABLE AS
    RETURN
SELECT 
    YEAR(EntBookings.BookingDate) AS Duration, 
    Sum(dbo.EntBookings.ItemCost) AS totalcost,
WHERE   EntBookings.BranchId = @BrachId
GROUP BY Year(EntBookings.BookingDate)

Again, I am using GROUP BY Year() that does the work great, but I need to modify it to take the fy i.e. (1 April to 31 March). How can I do it?

  • 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-10T13:33:52+00:00Added an answer on June 10, 2026 at 1:33 pm

    try this:

    SELECT 
        case when month(EntBookings.BookingDate) <4
             then YEAR(EntBookings.BookingDate)-1
             else YEAR(EntBookings.BookingDate) end  AS Duration, 
        Sum(dbo.EntBookings.ItemCost) AS totalcost
    WHERE   EntBookings.BranchId = @BrachId
    GROUP BY case when month(EntBookings.BookingDate) <4 
             then YEAR(EntBookings.BookingDate)-1 
             else YEAR(EntBookings.BookingDate) end as [year]
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a data object that is deep-cloned using a binary serialization. This data
I have this script that collects data from users and I want to check
I have this SQL Query that pulls data from 3 tables. I am unable
I have this function in jQuery that gets data from a page with POST,
I have this following setup, a textarea named with some data in it that
I have text stored in SQL as HTML. I'm not guaranteed that this data
I have data that looks like this: #info #info2 1:SRX004541 Submitter: UT-MGS, UT-MGS Study:
I have a data that looks like this . And I intend to create
I have a data that looks like this . And my code below simply
I have several data that looks like this: Vector1_elements = T,C,A Vector2_elements = C,G,A

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.