Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Search results for query: *

  1. pwilson

    Join With Min(date)

    The MinID makes sense. I dropped the Date=Date and it works the same. thanks for the help.
  2. pwilson

    Join With Min(date)

    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...
  3. pwilson

    Join With Min(date)

    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.
  4. pwilson

    Join With Min(date)

    ...rule') INSERT INTO TestDateLog(DateItem,EmpID,Note)VALUES('12/12/2006',3,'i like elephants') SELECT * FROM TestEmp E LEFT OUTER JOIN (SELECT DL.DateItem,DL.ID,DL.EmpId,DL.Note FROM TestDateLog DL INNER JOIN (SELECT MIN(DateItem) AS DateItem, EmpID...
  5. pwilson

    ISO Weeks

    ...SET @firstdayyear = (SELECT DATEADD(yy,DATEDIFF(yy,'1/1/2000',DATEADD(yy, SIGN(-1*(SIGN(DATEPART(dy,DATEADD(dd,-1,DATEADD(yy,1,@seed))) - DATEPART(dy,@finddate) -3 + DATEPART(dw,@finddate))-1)) +...
  6. pwilson

    ISO Weeks

    ...SELECt DATEPART(yy, DATEADD(yy, SIGN(-1*(SIGN(DATEPART(dy,DATEADD(dd,-1,DATEADD(yy,1,@seed))) - DATEPART(dy,@finddate) -3 + DATEPART(dw,@finddate))-1)) + SIGN(SIGN(DATEPART(dy,@finddate) -8+DATEPART(dw,@seed))-1)...
  7. pwilson

    Better Database design?

    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...
  8. pwilson

    SQL weirdness

    Why does the second one not work. Is it because the IN function goofs on the null or what?
  9. pwilson

    SQL Server Puzzle #5: Points Within Polygon

    ...Set @StartTime = GetDate() DECLARE @maxpoint int SELECT @maxpoint = MAX(PointNumber) FROM MapPoints Set @EndTime = GetDate() SELECT COUNT(*) AS Total FROM ( SELECT LocationId FROM MapCountiesPoints MP1 INNER JOIN MapCountiesPoints MP2 ON MP1.PointNumber = (MP2.PointNumber +...
  10. pwilson

    SQL Server Puzzle #5: Points Within Polygon

    I figured that one out after I posted. I did the algorithm wrong. Ok now im down to 3754 in 13.36
  11. pwilson

    SQL Server Puzzle #5: Points Within Polygon

    I am getting 3854. Are there 1464 MapPoints and 4166 Locations?
  12. pwilson

    SQL Server Problem #2: data dump

    In researching how to do it I found one that does most of what was asked. Didnt want to plagiarize or redo it.
  13. pwilson

    SQL Server Puzzle:Prime Numbers

    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
  14. pwilson

    SQL Server Puzzle:Prime Numbers

    ...This is because of the following in the list 1,2,3,4,5,6 if you delete the multiples of 2 then you have 1,2,3,5 So if we are looking at 1-10000 100*100 = 10000 So we have to check from 1-100 this is because any Numbers that are not prime above the SQRT will be in the form a*b where a>100 and...
  15. pwilson

    Learn SQL Server the hard way

    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...
  16. pwilson

    SQL Server Puzzle:Prime Numbers

    Very fun problem. Making me think I have ~34 seconds with ~6 seconds of table generation.
  17. pwilson

    SQL puzzles

    Changing the +6 to +5 then maving the +1 to the outside seems to do it declare @WhichDay tinyint -- US English datefirst assumed (1 - Sunday) declare @StartDate datetime set @StartDate = '20060111' set @WhichDay = 4-- next wed 1-18 //1-18 SET DATEFIRST 7 SELECT...
  18. pwilson

    SQL puzzles

    declare @WhichDay tinyint -- US English datefirst assumed (1 - Sunday) declare @StartDate datetime set @StartDate = '20060111' set @WhichDay = 1-- next Sunday, result should be Jan 15th //returns 1-16 SET DATEFIRST 7 SELECT (6 + (@WhichDay + DATEPART(dw, @StartDate))) % 7 + @StartDate +...
  19. pwilson

    SQL puzzles

    ok then DECLARE @nextday int SET @nextday = 7 SET DATEFIRST 1 SELECT DATEADD(dd,DATEDIFF(dd,'1/1/1900',getdate()) + (@@DateFirst + @nextday + DATEPART(dw,Getdate())) % 7 +1,'1/1/1900') SET DATEFIRST 3 SELECT DATEADD(dd,DATEDIFF(dd,'1/1/1900',getdate()) + (@@DateFirst + @nextday +...
  20. pwilson

    SQL puzzles

    DECLARE @nextday int SET @nextday = 7 SELECT DATEADD(dd,DATEDIFF(dd,'1/1/1900',getdate()) + (@nextday + DATEPART(dw,Getdate())) % 7 +1,'1/1/1900')

Part and Inventory Search

Back
Top