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
You are designing a strategy for synchronizing an SQL Azure database and multiple remote Microsoft SQL Server 2008 databases. The SQL Azure database contains many tables that have circular foreign key relationships?
Explain the difference between cross join and full outer join?
What is the use of =,==,=== operators?
When would you prefer to have a minimum number of indexes?
How will you know when statistics on a table are obsolete?
Explain SSRS Architecture?
Explain the different index configurations a table can have?
How do I partition a table in sql server?
Why do we use sql limitations? Which constraints can we use while making a database in sql?
What causes index fragmentation?
What is lock escalation? : sql server database administration
How can we delete a table in sql server?
According to you what goes into making the best database administrator? : sql server database administration
What is an index in sql?
What is a select query statement in ms sql server?