Viewing 15 posts - 166 through 180 (of 898 total)
Change the final SELECT statement to something like this
SELECT*, CAST( ( game1 + game2 + game3 + game4 + game5 ) / 5.0 AS NUMERIC(10,1) ) AS [percent]
FROMcte_Students
June 14, 2013 at 3:44 am
Can you post the query you are using. That might give us some idea.
June 14, 2013 at 3:34 am
Teee (6/13/2013)
@kingston Dhasian, Thank you so much for the script that's returning the dates it works perfectly.
I am glad it worked for you and I hope you understand what...
June 13, 2013 at 7:57 am
One way to achieve the results..
DECLARE @datefrom DATETIME
DECLARE @dateto DATETIME
SET@datefrom = '01/01/2013'
SET@dateto = DATEADD(DAY,-1,DATEADD(MONTH,DATEDIFF(MONTH,0,CURRENT_TIMESTAMP)-2,0))
SELECT @datefrom,@dateto
June 13, 2013 at 6:55 am
Something like this?
DECLARE@min-2 DATETIME
DECLARE@max-2 DATETIME
SELECT@min-2 = MIN(dtePostedToWebsiteDate)
FROMdtlVacancyPostAudit
WHEREbitPostToWebSite = 1
SET@max-2 = DATEADD(MONTH,DATEDIFF(MONTH,0,CURRENT_TIMESTAMP)+1,0)
SELECTDATENAME(MONTH,@min) AS MinMonth,
YEAR(@min) AS MinYear,
DATEADD(MONTH,sv.number,@min)
FROMmaster.dbo.spt_values AS sv -- You can use a Tally table instead as well
WHEREsv.type = 'P'
ANDDATEADD(MONTH,sv.number,@min) <...
June 13, 2013 at 6:47 am
One way to achieve the results
DECLARE @YourTableName TABLE
(
ColumnName VARCHAR(20)
)
INSERT@YourTableName
SELECT'10.12.2012' UNION ALL
SELECT'12-10-2012' UNION ALL
SELECT'2012/10/12'
SELECTCASE
WHEN ColumnName LIKE '%.%' THEN CONVERT(DATETIME,ColumnName,104)
WHEN ColumnName LIKE '%-%' THEN CONVERT(DATETIME,ColumnName,110)
WHEN ColumnName LIKE '%/%' THEN CONVERT(DATETIME,LEFT(ColumnName,5)+RIGHT(ColumnName,2)+SUBSTRING(ColumnName,5,3),111)
END AS NewColumn,...
June 13, 2013 at 5:50 am
One small observation..
Its not a good idea to use a function in your WHERE clause if you can avoid it as it makes the query non-SARGable
You can modify Mark's code...
June 13, 2013 at 4:02 am
tshad (6/12/2013)
But I need to do this in a where clause, possible using a subquery but how do I use the "BETWEEN" there?
Why? Any particular reason?
SELECT *
FROM @Client cl
JOIN...
June 13, 2013 at 2:56 am
It happened because the data types for columns game1, game2,...game5 were taken as VARCHAR
The below code will avoid the issue
; WITH cte_Students AS
(
SELECT*,
CASE WHEN SUBSTRING(rate, 1, 1) = '*' THEN...
June 13, 2013 at 2:10 am
It would be really helpful if you provide the DDL of the tables Employee and Supervisor
Some sample data and the expected results based on the sample data would help us...
June 12, 2013 at 6:58 am
What input will you be passing to the UDF?
It would be helpful if you can us the DDL of the table "tblHoliday" as well.
June 12, 2013 at 6:45 am
You can use a CTE or a Derived table like this
; WITH cte_Students AS
(
SELECT*,
CASE WHEN SUBSTRING(rate, 1, 1) = '*' THEN '10' ELSE SUBSTRING(rate, 1, 1) END AS game1,
CASE WHEN...
June 12, 2013 at 2:55 am
Do you really want to update all the 63 million rows?
Check if you can put some filter to reduce the number of rows that will be affected.
June 7, 2013 at 6:36 am
The link below has the answer to your question
http://msdn.microsoft.com/en-us/library/ms175009.aspx
If an integer dividend is divided by an integer divisor, the result is an integer that has any fractional part of the...
June 7, 2013 at 4:40 am
Viewing 15 posts - 166 through 180 (of 898 total)