We value your feedback.
Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!
IF EXISTS (SELECT * FROM SYSOBJECTS WHERE ID = OBJECT_ID(N'[dbo].[usp_SF6_GetCylinderBOY]') AND OBJECTPROPERTY(id, N'IsProcedure') = 1) DROP PROCEDURE [dbo].[usp_SF6_GetCylinderBOY] GO CREATE PROCEDURE [dbo].[usp_SF6_GetCylinderBOY] @CompanyID int, @YearPartDate datetime AS BEGIN SELECT SUM(GasWeight) FROM ( select we.ContainerID, we.GasWeight, row_number() over (partition by we.ContainerID order by we.DateStamp desc) rn FROM [WeighingEvents] we JOIN [Container] c ON we.[ContainerID] = c.[ContainerID] WHERE c.ContainerTypeID = 1 AND we.[CompanyID] = @CompanyID AND we.[Active] = 1 AND (YEAR(we.[DateStamp]) = YEAR(@YearPartDate)) ) sq WHERE rn = 1 END GO
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
|SQL Syntax to get a value associated with most recent date||16||63|
|PHP - How to insert data using sqlsrv on stored procedure?||8||60|
|connection to SQL 2012 error in windows 10||18||45|
|SQL Server and Access Database (Project Codes) get the next record||43||32|
Join the community of 500,000 technology professionals and ask your questions.