Its an ugly hack but this works.
SELECT *
FROM TestEmp E LEFT OUTER JOIN
(SELECT DL.DateItem,DL.ID,DL.EmpId,DL.Note
FROM TestDateLog DL INNER JOIN
(SELECT MIN(DATEADD(ms,ID,DateItem)) AS DateItem, EmpID
FROM TestDateLog
GROUP...
Well say note is a text field.
ALTER TABLE TestDateLog ALTER COLUMN Note text NULL
The text, ntext, and image data types are invalid in this subquery or aggregate expression.
And what if there are more columns than just Note to be pulled from TestDateLog.
Thanks for looking at it.
Employees
Id Name
1 Joe
2 Carol
3 Susan
DateLog
ID date Employee Note
1 10-1 1 Fun
2 10-1 1 Great
3 10-10 3 monkeys rule
3 12-12 3 i like elephants
So I want All employees with their earliest date applied, but also the...
Ok this looks like it works
ALTER PROCEDURE ISODates
@finddate datetime
AS
SET DATEFIRST 1
DECLARE @seed datetime
DECLARE @firstdayyear datetime
SET @seed = (SELECT DATEADD(yy,DATEDIFF(yy,'1/1/2000',@finddate),'1/1/2000'))
SET @firstdayyear = (SELECT...
This is close. It messes up on the week for 12/29/2009, 1 instead of 53.
ALTER PROCEDURE ISODates
@finddate datetime
AS
SET DATEFIRST 1
DECLARE @seed datetime
SET @seed = (SELECT DATEADD(yy,DATEDIFF(yy,'1/1/2000',@finddate),'1/1/2000'))
SELECt DATEPART(yy...
FYI: we dont have daylight savings where I live ...
along the daylight saving thing what happens in the time that that occurs.
Say that 2Am (or whenever daylight saving starts) you make some records
4-1-2004 2.00.01 am
4-1-2004 2.01.01 am
4-1-2004 2.02.01 am
4-1-2004 2.03.01 am
then at...
My eratosthenes took about 10 secs longer than that
replacing the Join part with
DECLARE @i int
SET @i = 2
WHILE @i < SQRT(@NumRows)
BEGIN
DELETE FROM #t WHERE RowNum%@i=0 AND RowNum > @i
SET @i = (SELECT MIN(RowNum) FROM #t where RowNum>@i)
END
Here is mine
Found the Table generation from this site. Modded it to be from
n^2 to n^n with a limit so i wouldnt be joining 100000 twice.
#t is numbers 1 to @NumRows
#j is numbers 1 to SQRT(@NumRows)
This is because of the following
in the list 1,2,3,4,5,6 if you delete the multiples of 2...
On a Sybase app I was creating a package that pulled some random numbers. so i did something like
SELECT Rand(Column * (datepart(ms,getdate()))
Well on sybase the seed you pass in there is a global seed. There was a row with a zero causing the rand(0) = 0.
Since Sybase sets the seed to a...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.