Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


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.



how we can count records as a group of days like sum of records for(four mondays),(four tuesday).....

Answer / 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

More SQL Server Interview Questions

Explain transaction isolation levels in sql server?

0 Answers  


What do you mean by sql server 2005 express management tools?

0 Answers  


How to see the event list of an existing trigger using sys.trigger_events?

0 Answers  


Can a database be shrunk with users active?

0 Answers  


Explain what are page splits? : SQL Server Architecture

0 Answers  


What is the maximum size of a row in sql server?

0 Answers  


Write a stored procedure for emplpoyee and department table to get DeptName which having no employee. Table Structure- Emp-Emp_Id,Emp_Name,Dept_id Dept-Dept_Id,Dept_Name

7 Answers   TCS,


How to insert data into an existing table?

0 Answers  


Issues related in upgrading SQL Server 2000 to 2005 / 2008

0 Answers  


What do you understand by hotfixes and patches in sql server?

0 Answers  


Explain about SQL server 2005?

0 Answers  


What is a coalesce function?

0 Answers  


Categories