Forum Replies Created

Viewing 12 posts - 886 through 897 (of 897 total)

  • RE: how to flag duplicate records but diff quantity

    Try this. This works for the data provided. You can do additional changes for any other data.

    create table #x

    (phno int,

    Description varchar(20),

    qty int,

    amt money)

    insert into #x values(123,'abc',1,60)

    insert into #x values(123,'abc',-1,60)

    insert into...

  • RE: complex query

    Even this should work, say the name of table is Employees and the name of the column is DateOfJoin.

    SELECT*

    FROM Employees

    WHEREDATEPART( DAY, DATEADD( DAY,...

  • RE: Update column using inner join

    Well. I never thought it can be done this way. Thanks for the additional info Ramesh.

  • RE: Update part of a value in many rows

    You can use the REPLACE function

  • RE: Update column using inner join

    Glad to help you out.

    Regards,

    Kingston

  • RE: Update column using inner join

    Sorry Try this one ..

    Try this. I hope this works..

    ;WITH cteTable AS

    (

    SELECT ROW_NUMBER() OVER ( PARTITION BY zipcode ORDER BY datevalue ) AS RowNumber, *

    FROM ...

  • RE: Update column using inner join

    Sorry Try this one ..

    ;WITH cteTable AS

    (

    SELECT ROW_NUMBER() OVER ( PARTITION BY officecode ORDER BY datevalue ) AS RowNumber, *

    FROM ...

  • RE: Update column using inner join

    Try this..

    ;WITH cteTable AS

    (

    SELECT ROW_NUMBER() OVER ( PARTITION BY officecode ORDER BY datevalue ) AS RowNumber, *

    FROM#Table

    )

    UPDATET

    SET ...

  • RE: Add a dynamic column in Query that calcs on prior rows?

    Sorry for the error. I actually missed see the forum name. I think we can use the table variables or temporary tables with an identity column to solve this problem.

  • RE: Add a dynamic column in Query that calcs on prior rows?

    ;WITH cteCountSpeed AS

    (

    SELECTROW_NUMBER() OVER ( ORDER BY Col1 ) AS Row, *

    FROMtblCountSpeed

    )

    SELECTC1.Col1, C1.col2, ( C2.Col2 - C1.Col2 ) / ( C2.Col1 - C1.Col1 ) AS QueryColumn

    FROMcteCountSpeed C1

    LEFT OUTER JOIN cteCountSpeed...

  • RE: Date, period, spell

    INSERT INTO #PresentInfamily

    SELECT * FROM #FamilyMembers

    DECLARE@strSQLVARCHAR(MAX)

    SELECT@strSQL = COALESCE( @strSQL, '' )

    + ' INSERT INTO #PresentInfamily( IndividualNo, MemberInFamilyID, PresentStartDate, PresentEndDate ) '

    + ' SELECT IndividualNo, MemberInFamilyID, ''' + CAST( DATEADD( DAY,...

  • RE: How to change group by result. please...

    Actually your code has put me in confusion with the names.

    But just try if this works or if you get some idea

    SELECT b.divid,sum(a.Amount)

    FROM DailyTrans a,accounts_Info b

    WHERE a.acctID=b.acctID

    and (b.DivCode = 'AAA')...

Viewing 12 posts - 886 through 897 (of 897 total)