## [Solved] Simplest way to fill working day table

You can use a recursive CTE to accomplish this. This only excludes the weekends. Using DATEFIRST you can figure out what day is a weekend. This query should work no matter what day of the week is set to DATEFIRST. ;WITH DatesCTE AS ( SELECT CAST(‘2016-01-01’ AS DATE) AS [workingDays] UNION ALL SELECT DATEADD(DAY, 1, … Read more

## [Solved] How can calculate distance in feet between two places? [closed]

If you have the distance in miles, all you have to know is the conversion from miles to feet: 1 mile == 5,280 feet Are the calculations you posted incorrect in some way? http://www.google.com/search?gcx=c&sourceid=chrome&ie=UTF-8&q=convert+miles+to+feet solved How can calculate distance in feet between two places? [closed]

## [Solved] mysql : check if column id is Consecutive [closed]

You can get the gaps by looking at the previous row. If your table is not too large: select (t.prev_id + 1) as first_missing, (t.id – 1) as last_missing, (t.id – t.prev_id – 1) as cnt from (select t.*, (select max(t2.id) from t t2 where t2.id < t.id ) as prev_id from t ) t … Read more

## [Solved] Calculate number of leaves taken by Employee in a month in SQL Server

Use SUM and GROUP BY. SELECT Empid, SUM([No of Days]) AS Days FROM leavetable GROUP BY Empid Read more here GROUP BY and here SUM. This would give you: Empid Days 100 25 Or if you mean count the amount of times an employee has been off use Count. SELECT Empid, Count(Leaveid) AS LeaveTotal FROM … Read more

## (Solved) How can I prevent SQL injection in PHP?

The correct way to avoid SQL injection attacks, no matter which database you use, is to separate the data from SQL, so that data stays data and will never be interpreted as commands by the SQL parser. It is possible to create an SQL statement with correctly formatted data parts, but if you don’t fully … Read more