how we can count records as a group of days like sum of
records for(four mondays),(four tuesday)........ in a month.
group the column for weekdays.
Answer Posted / harshad lakkad (bapunagar) par
--First Create This Function To Return a week Days For
Particular Date--
CREATE FUNCTION [dbo].[udf_DayOfWeek]
(@dtDate DATETIME)
RETURNS VARCHAR(10)
AS
BEGIN
DECLARE @rtDayofWeek VARCHAR(10)
SELECT @rtDayofWeek = CASE DATEPART(weekday,@dtDate)
WHEN 1 THEN 'Sunday'
WHEN 2 THEN 'Monday'
WHEN 3 THEN 'Tuesday'
WHEN 4 THEN 'Wednesday'
WHEN 5 THEN 'Thursday'
WHEN 6 THEN 'Friday'
WHEN 7 THEN 'Saturday'
END
RETURN (@rtDayofWeek)
END
--Now Use this Function As Below
SELECT
Sum(Bank.Amount),
dbo.udf_DayOfWeek(Bank.Date) AS DayOfWeek
From Bank
Group By Bank.Date
-- Here Bank.Amount And Bank.Date Are Column Name Of Bank
Table
Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
What changes in the front end code is needed if mirroring is implemented for the high availability? : sql server database administration
Explain multiserver query
Explain for xml explicit mode?
Can a stored procedure call itself or a recursive stored procedure? How many levels of sp nesting is possible?
What is a result set object returned by odbc_exec()?
How can I check if a view exists in a sql server database?
what is isolation level at dead lock?
What are dml triggers and types of dml triggers?
What are the different types of backups avaialabe in sql server 2005?
What is 2nf example?
What is the difference between a function and a trigger?
Explain the cursor lock types?
What are the steps to insert a table?
What is star, snowflake and star flake schema? : sql server analysis services, ssas
What are parameterized reports?