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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T05:00:42+00:00 2026-05-26T05:00:42+00:00

Hi I have the next store procedure `USE [BD_SSEGUA] GO / * Object: StoredProcedure

  • 0

Hi I have the next store procedure

`USE [BD_SSEGUA]
GO
/* Object: StoredProcedure [dbo].[spAgendaDeSolicitudes] Script Date: 10/14/2011 16:43:00 */
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
— =============================================
— Author: Roque Ramírez Nájera
— Create date: 23/03/2011
— Description: Genera tabla de solicitudes
— por estatus y año
— spAgendaDeSolicitudes ‘2010’
— =============================================

ALTER PROCEDURE [dbo].[spAgendaDeSolicitudes]

@anio  varchar(5)
AS
     DECLARE

     @ContR     int,
     @ContRA        int,
     @ContRZ        int,
     @ContB     int,
      @ContC        int,
     @total     int

    DECLARE

     @agenda table ( periodo datetime, R int, A int, RZ int, B int, C int, TOTAL int)


      BEGIN



SET NOCOUNT ON;

SELECT @ContR = COUNT (fiIdSolicitud) FROM Solicitud WHERE fiEdoSolicitud = 1 and fiAnioSolicitud = @anio
SELECT @ContRA = COUNT (fiIdSolicitud) FROM Solicitud WHERE fiEdoSolicitud = 2 and fiAnioSolicitud = @anio
SELECT @ContRZ = COUNT (fiIdSolicitud) FROM Solicitud WHERE fiEdoSolicitud = 3 and fiAnioSolicitud = @anio
SELECT @ContB = COUNT (fiIdSolicitud) FROM Solicitud WHERE fiEdoSolicitud = 4 and fiAnioSolicitud = @anio
SELECT @ContC = COUNT (fiIdSolicitud) FROM Solicitud WHERE fiEdoSolicitud = 5 and fiAnioSolicitud = @anio

SET @total = @ContR + @ContRA + @ContRZ + @ContB + @ContC

INSERT INTO @agenda  (R, A, RZ, B, C, TOTAL)
VALUES(@ContR,@ContRA,@ContRZ,@ContB,@ContC,@total)

SELECT R, A, RZ, B, C, TOTAL FROM @agenda END

`

I use this sp to fill a telerik radgrid the stored procedure gets as a result the count of requests per year sorted by status, this result is populated in a telerik radgrid.
R is for Registered
A is for Authorized
RZ is for Rejected and so on.

What I want to do is to group the results per year,month,week from the current year.
But the only field that I have is a datetime that corresponds the registration date which is in another table.

How can I solve this?
Hope your help.

  • 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-05-26T05:00:42+00:00Added an answer on May 26, 2026 at 5:00 am

    to group your data, you can create a CTE to add year/month/week corresponding to the datetime field and make your aggregate function in the CTE

    here an example where I suppose that your temp table @agenda contains all the necessary data:

    ;WITH myCTE AS 
    (
        SELECT 
            periodo, 
            YEAR(periodo) AS yearPart,
            MONTH(periodo) AS monthPart,
            DATEPART(WEEK, periodo) AS weekPart,
            R, A, RZ, B, C, 
            TOTAL int
        FROM @agenda
    )
    SELECT 
        yearPart, monthPart, weekPart, 
        SUM(R) AS R, SUM(A) AS A, SUM(RZ) as RZ, SUM(B) AS B, SUM(C) AS C, 
        SUM(TOTAL) AS TOTAL
    FROM myCTE
    GROUP BY yearPart, monthPart, weekPart
    

    Hope this helps 🙂

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

Sidebar

Related Questions

I have the next query that I run via SQLCMD.EXE use [AxDWH_Central_Reporting] GO EXEC
I have to do a big update script - not an SPL (stored procedure).
I have a java code that use a stored procedure for that it is:
I have next tables Order , Transaction , Payment . Class Order has some
I have next code require 'rack/rpc' class Server < Rack::RPC::Server def hello_world Hello, world!
I have next problem, when I'm trying to retrieve value from xforms:select elements I
I have next problem: i have a View: <UserControl x:Class=WpfApplication1.UserControl1 xmlns=http://schemas.microsoft.com/winfx/2006/xaml/presentation xmlns:x=http://schemas.microsoft.com/winfx/2006/xaml xmlns:mc=http://schemas.openxmlformats.org/markup-compatibility/2006 xmlns:d=http://schemas.microsoft.com/expression/blend/2008
I have next html: <label for="user_name"> <abbr title="required">*</abbr> Name </label> And I want to
I have next function for autocomplete an input: $(#auto).autocomplete({ source:/autocomplete.php, minLength: 5, _renderItem: function(
I have next package structure webService.ear -- dependency.jar -- some.class Can I remove some.class

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.