Forum Replies Created

Viewing 15 posts - 3,781 through 3,795 (of 4,087 total)

  • RE: Need the Price with the Latest Date

    What have you tried already and where are you running into problems? I'd recommend looking at Row_Number() or other ranking functions.

    Drew

  • RE: Pivot the result of the select statement

    krishusavalia (1/31/2011)


    Garadin,

    I appriciate your fast responce.

    But in my actual xml file i have name space so in the code i am declaring the name space.

    ;WITH XMLNAMESPACES(default 'http://schemas.xmlaaaa.org/aaaaenv/envelope/')

    so when i am...

  • RE: Create CSV list from rows, SQL 2000

    FOR XML PATH was introduced in SQL 2005 and varchar(max) was also introduced in SQL 2005. The OP already told you that he couldn't use FOR XML PATH.

    Drew

  • RE: join but distinct from third table

    Sailor (1/28/2011)


    I got better information...They want just the first account number.

    select name, table2.account, table3.city

    from table1

    left join table2 on table1.userid = table2.userid

    left join (select top 1 account from table3)

    as tab3 on...

  • RE: join but distinct from third table

    I forgot to include the ON statement.

    Drew

  • RE: need help to select rows

    GSquared (1/27/2011)


    ;WITH MaxDates (OrderID, MaxDate) AS

    (SELECT OrderID, MAX(OrderDate)

    FROM MyTable

    GROUP BY OrderID)

    SELECT T1.*

    FROM MyTable AS T1

    LEFT JOIN CTE

    ON T1.OrderID = CTE.OrderID

    AND T1.OrderDate = CTE.MaxDate

    WHERE CTE.OrderID IS NULL;

    This approach is inefficient, because...

  • RE: join but distinct from third table

    I'm not sure why you're joining to your table3 twice, but that is what is causing the problem. The first join is okay, because of the distinct clause, but...

  • RE: Create CSV list from rows, SQL 2000

    You know that there is a separate forum for SQL 2000/7.0.

    You should read Jeff's article about the "quirky" update. http://www.sqlservercentral.com/articles/68467/. There are a lot of caveats for "quirky"...

  • RE: Merge rows into columns

    PIVOT won't work, because you need to pivot two columns (Col2 and Col3) and PIVOT will only work with one column. However, you are doing an aggregate, even though...

  • RE: improve the query performance

    dlam 18073 (1/20/2011)


    but is there any different between puting the where clause in the sub-query and out side the sub-query

    Absolutely. The WHERE clause in the main query would be...

  • RE: Select data for a year

    You should use DateDiff() instead. Converting datetime data back and forth between char data is inefficient.

    WHERE DateDiff(Month, DateTimeIn, GetDate()) < 12

    Drew

  • RE: CASE in WHERE clause

    Deeptiprasad (1/19/2011)


    Ideally the query should be like this

    WHERE ID =

    CASE

    WHEN @ID >0 THEN @CaseID

    WHEN @ID = 0 THEN (RMARequestedDate > (GetDate()- @d))

    END

    "(RMARequestedDate > (GetDate()- @d))" is a Boolean...

  • RE: improve the query performance

    Your query is using hidden RBAR which is why it is inefficient. You're better off using the Row_Number() function with the Partition By option to find the last call...

  • RE: Calculating Delta values for each day

    Carl Federl (1/18/2011)


    First one needs to get the date only from the datetime column using this method:

    1. subtract one-half of a day and subtract 2 milliseconds, which is 43200002 milliseconds.

    2....

  • RE: ISNULL of an INTEGER

    Rydunzel (1/17/2011)


    This isn't an issue with the ISNULL funtion, it is just how the integer zero is treated.

    No, it's how the STRING '' is treated and it follows logically from...

Viewing 15 posts - 3,781 through 3,795 (of 4,087 total)