Forum Replies Created

Viewing 15 posts - 766 through 780 (of 1,923 total)

  • RE: Grouping by Running Total

    How about this?

    ; WITH RecrusiveCTE AS

    (

    SELECT ID, FieldA , FieldB, fieldC , Int1 , Int1 AS RngTotal , 1 AS Ranker

    FROM list_1

    WHERE ID = 1

    UNION ALL

    SELECT OrigTable.ID , OrigTable.FieldA ,

    ...

  • RE: Query Question

    mikes84 (5/19/2011)


    ColdCoffee,

    Anyway, the one piece I think it's missing is a line that has Joe, ST, CoveredByBase, then all nulls for security. Is there a way to incorporate that?

    Yeah, i...

  • RE: Need help tweaking a random query

    Probably this?

    declare @DateFrom as datetime

    declare @DateTo as datetime

    set @DateFrom = dateadd(week, datediff(week, 0, getdate()) - 1, -1) -- first day of previoius week

    set @DateTo = dateadd(ms,-3,DATEADD(wk, DATEDIFF(wk,0,getdate()),...

  • RE: Query Question

    For the test data you provided, i get the same results... can u please run it again and check?

  • RE: Query Question

    Awesome way of asking a question, Mike 🙂 Thanks for that...

    This might help you:

    ; WITH DistUserCnt AS

    (

    SELECT Department, COUNT(DISTINCT UserID) DistUsrCnt

    FROM Permissions

    GROUP BY Department

    )

    , BaseGrps AS

    (

    SELECT 'Base' UserID, Application...

  • RE: Select Only IDs that match all entries in another table

    Lynn Pettis (5/18/2011)


    I know I'm late to the party, but I was reading the question and I'm partially lost, in that I'm not sure what your expected results are based...

  • RE: date time question

    Something like this?

    DECLARE @TableOfDatesAndTimes Table

    (

    Dates VARCHAR(8) ,

    Times VARCHAR(4)

    )

    --== Populate with test data

    --== this is what u missed in the post ; Please provide sample data

    INSERT INTO...

  • RE: How to find average when some of the fields contain null value?

    abhisheksrivastava85 (5/17/2011)


    But do you think this solution is making our query more expensive because if have more number of columns then using case and isnull in denominator is challenge. And...

  • RE: T-sql to Concatenate the rows

    Try this:

    declare @Mytable as table(

    SrNO int identity(1,1),

    skillwllfsh int,

    skillvideo int,

    skillchsi int,

    skillchn int,

    skillcdv int,

    skillcco int,

    skillrpts int

    )

    insert into @Mytable (skillwllfsh, skillvideo, skillchsi, skillchn, skillcdv, skillcco, skillrpts) values

    (1, 1, 1, 1, 1, 1, 0),...

  • RE: distinct/grouping problem

    Try this:

    ; WIHT CTE AS

    (

    SELECT RN = ROW_NUMBER() OVER ( PARTITION BY ReferenceNo , CODE ORDER BY Date DESC )

    , *

    FROM CTE ...

  • RE: How to find average when some of the fields contain null value?

    Have u tried the other solutions posted?

  • RE: How to find average when some of the fields contain null value?

    Two ways i could think of:

    METHOD 1

    DECLARE @Table Table

    (

    COL1 INT,

    COL2 INT,

    COL3 INT,

    COL4 INT

    )

    INSERT INTO @Table VALUES

    (11, 12, 11,...

  • RE: 'staggered' sort

    mister.magoo (5/15/2011)


    order by abs(rownum-(total_count/2)) DESC,Value desc

    This is exactly what i had in my mind 🙂 Nicely done, MM...

  • RE: 'staggered' sort

    Few questions here :

    1. How big a table is yours ?

    2. Do u have IDENTITY column or any "numbered" column that can uniquely find a row in your table ?

    This...

  • RE: query on checking servers

    mnagasrikanth219 (5/10/2011)


    How to check the servers in production/use?

    By loggin in 😀

Viewing 15 posts - 766 through 780 (of 1,923 total)