Forum Replies Created

Viewing 15 posts - 931 through 945 (of 3,957 total)

  • RE: SLICING DATA IN A TABLE

    Luis Cazares (1/8/2014)


    I'm sure that this is a running total problem that I would love to try with SQL 2012, but I don't have it at work.

    I agree and I...

  • RE: Need help with max value in date column

    Always the bridesmaid and never the bride.

  • RE: help with insert query

    Luis - This is nice! Also out of the box.

    select [object_id]

    INTO #TableB

    from sys.all_objects

    WHERE 1=2

    Another way that I would certainly never try at home myself.

    select [object_id]

    INTO #TableB

    from sys.all_objects

    WHERE...

  • RE: I need a query.. kind of hieararchy finding query

    Sean Lange (1/8/2014)


    ...

    This gets almost what you state you are looking for. It does not return 80, 40 but I can't understand from your data why you think that one...

  • RE: Select statement to show users in more than one company

    ChrisM@Work (1/8/2014)


    ..

    (you didn't see that table spool)

    ...

    I did.

  • RE: T-SQL Help

    Christian Graus (1/7/2014)


    *facepalm* Sorry, I keep an eye on several forums, I forgot this one had that level of granularity....

    No reason to be embarrassed or sorry. Jeff was...

  • RE: How to tell if your code is executing inside sp_ExecuteSQL?

    Does this give you the output you're looking for?

    Print REPLICATE(' ', @@NestLevel) + CAST(@@NestLevel AS VARCHAR);

    Exec('Print REPLICATE('' '', @@NestLevel) + CAST(@@NestLevel AS VARCHAR);');

    Exec sp_ExecuteSQL N'Print REPLICATE('' '', @@NestLevel) + CAST(@@NestLevel...

  • RE: Need help with max value in date column

    Another way (similar to Christian's):

    WITH PreAggregate AS

    (

    SELECT employee_id, date_joined, date_=MAX(date_)

    FROM #employee

    GROUP BY employee_id, date_joined

    )

    SELECT employee_id, date_joined, date_, SomeCalculatedColumn

    FROM...

  • RE: T-SQL Help

    Christian Graus (1/7/2014)


    Am I right in thinking your solution requires SS2012 ? Did we discuss that already ?

    Yes absolutely. This is the SQL 2012 forum after all.

  • RE: T-SQL Help

    PSB (1/7/2014)


    ...

    For Grp A , where create DAte = '2013-01-01 00:00:00.000' and OpenticketsTillDate = 1, The ClosedTicketTillDate should be 3( Tickets which have ClosedDate on or after 1/1/2013 are 2013-11-23...

  • RE: T-SQL Help

    This way returns the same results I reported above, but eliminates the triangular join caused by the correlated sub-query I was using originally, a.k.a. the one that Jeff groused about...

  • RE: T-SQL Help

    This is what the OP said he wanted as the results (originally):

    --The final result should look LIKE the below :

    SELECT 'A' AS [GROUP],'1/1/2013' AS CreateDate ,1 AS OpenedTicketstillDate, 3 AS...

  • RE: T-SQL Help

    Christian Graus (1/7/2014)


    My solution did not work if either value was zero. This does:

    DECLARE @date datetime = '2013-01-01'

    ;WITH opened

    AS(

    SELECT [group], count(1) as [count] FROM #TempTable WHERE cast(createDate as date)...

  • RE: T-SQL Help

    Jeff Moden (1/7/2014)


    dwain.c (1/6/2014)


    Jeff Moden (1/6/2014)


    [EDIT]... hmmm... although.... it might just be a RANK problem, now that I think about it a bit more.

    OK. You've got my attention. ...

  • RE: T-SQL Help

    Jeff Moden (1/7/2014)


    dwain.c (1/6/2014)


    Jeff Moden (1/6/2014)


    [EDIT]... hmmm... although.... it might just be a RANK problem, now that I think about it a bit more.

    OK. You've got my attention. ...

Viewing 15 posts - 931 through 945 (of 3,957 total)