Skip to main content

Posts

Get Day Wise Sale of the Week Using SQL Query or Store procedure, get Today Date, get Last Friday from SQL, Create Temporary table in SQL, Drop Temporary table From SQL Create PROCEDURE [dbo].[GetDaysOfTheWeek] AS BEGIN --Creating TEMP Table Create Table #Days (    TodayDate Varchar(12),    Sales decimal (18,2) ) DECLARE @Today DATE; DECLARE @LastFriday DATE; DECLARE @sale decimal (18,2); DECLARE @CurrentDate AS DATE; /*Get Last Friday And Store into @LastFriday Variable */ SET @LastFriday=(SELECT                     CASE WHEN (DATEPART(DW,GETDATE())< 7)                         THEN                             CONVERT(DATE,(DATEADD(dd,-(DATEPART(DW,GETDATE())+1),GETDATE())))    ...
Recent posts
Sales Report (SQL Procedure, Query) by Hourly, using while loop in SQL, Get Today Date from SQL, Temporary Table in SQL   CREATE PROCEDURE [GetSaleByHours] (   @Date datetime ) AS BEGIN Create Table #Day  -- Create primary Table to store hourly based sales (    hour bigint ) Declare @Count int = 0; WHILE @Count <= 23    -- Adding values to temp table using while loop  BEGIN       INSERT INTO #Day VALUES (@Count)     SET @Count = @Count + 1; END SELECT  @Date AS DAYDATE, dh.hour AS DAYHOUR ,ISNULL(SUM(ST.sales),0) AS Sales FROM #Day dh LEFT OUTER JOIN SalesTable ST  ON dh.hour = DATEPART(hh,ST.TimeStamp) GROUP BY dh.hour DROP TABLE #Day   -- Droping temp table END