Forum Replies Created

Viewing 15 posts - 1,561 through 1,575 (of 2,007 total)

  • RE: SUM relative to row date value

    The tally table is fine, it gives dates between 1900-01-01 and 7361-04-01 so you're unlikely to have hit the ceiling there 😛

    Try this: -

    --First, lets build some test data

    DECLARE @TABLE...

  • RE: Extracting a date from a varchar field

    How about this?

    (I've used SQL Server 2008 syntax, since that's the forum you posted in)

    CREATE FUNCTION [dbo].[Batchseriesdate] (@batchseriesno VARCHAR(16))

    RETURNS DATE

    AS

    BEGIN

    DECLARE @cleardate DATE

    ...

  • RE: SUM relative to row date value

    greg.bull (8/31/2011)


    On to the next point, if a month row is missing, then it'd be ignored, so for month 6, we'd be summing month 6, month 5 (which'd be null)...

  • RE: SUM relative to row date value

    greg.bull (8/31/2011)


    Confirming this:

    Month 4 would have metric2 as 9 - cos it would be 4+3+2.

    Month 5 would have metric2 as 12 (5+4+3).

    The problem would be that (and this is my...

  • RE: SUM relative to row date value

    ChrisM@Work (8/31/2011)


    What would be the value for month 5? Is the value 9 correct for month 4?

    DROP TABLE #Sample

    CREATE TABLE #Sample (Yearmonth DATE, Metric1 INT, Metric2 INT)

    INSERT INTO #Sample (Yearmonth,...

  • RE: SUM relative to row date value

    How's this?

    --First, lets build some test data

    DECLARE @TABLE AS TABLE (Yearmonth DATETIME, Metric1 INT, Metric2 INT)

    INSERT INTO @TABLE (Yearmonth, Metric1)

    SELECT '2010/01/01', 1 UNION ALL

    SELECT '2010/02/01', 2 UNION ALL

    SELECT...

  • RE: I have to find out DATE from start date & end date

    I've interpreted the problem differently to Gianluca, so there's a good chance that this doesn't do what you want, but feel free to check 🙂

    DECLARE @UserDate datetime

    SET @UserDate = '20110810'

    DECLARE...

  • RE: SQLQuery: Count both in where and in result

    Thanks for the sample data 🙂

    Not sure what version of SQL Server you're using.

    Try this (2005+ only)

    SELECT EmdId, EmpName, DeptName, MAX(rn) AS NumberofDependents

    FROM (SELECT e.EmdId, e.EmpFName + ' '...

  • RE: SQLQuery: Count both in where and in result

    Certainly!

    First though, please read this[/url] for information on how best to post a question that will get your question answered quickly.

    Thanks

  • RE: Find String like 'aaaaa' or 'bbbbbb' or 'cccccc' etc....

    peanuts91 (8/30/2011)


    Thanks Gianluca.

    But If I have a field containing for example 'Abraham', it will detect the A appears 3 times. But not 3 times in a row like aaa.

    How's this?

    DECLARE...

  • RE: Solving SUDOKU thru SQL Code

    Done some perf-tuning, requires a bit more but ran out of time for today.

    On my box

    Performed against the following "Givens" -

    ' 15 ...

  • RE: Conversion headache

    In SSRS, format the datetime column like this : -

    =Format(Parameters!DATETIMECOLUMN.Value,"dd/MM/yyyy")

  • RE: TSQL Challenge 63 - A TSQL Sudoku

    Funny this came up just after this discussion 🙂

  • RE: Solving SUDOKU thru SQL Code

    Didn't have time for perf-tuning last night, but this morning I quickly knocked up a conversion between the table from the SQL Challenge to a string so the rest of...

  • RE: Solving SUDOKU thru SQL Code

    SQLRNNR (8/23/2011)


    Nice. I thought about removing that table variable altogether last night after I posted. I put it in because I was getting weird results. But the...

Viewing 15 posts - 1,561 through 1,575 (of 2,007 total)