Forum Replies Created

Viewing 15 posts - 511 through 525 (of 1,347 total)

  • RE: DISTINCT problem

    Distinct only works on the entire row, regardless of where you place parentheses.

    Your issue is cardinality of data. The fact that you have a table named T_ContactTypeContact indicates that a...

  • RE: How to get a query to sort in memory not disk ?

    Here's an example of the impact, using temp tables, and just 10,000 rows. You can imagine what this scales to in your 800K sample. A SQL server data page is...

  • RE: How to get a query to sort in memory not disk ?

    >>Why should a "long" column in the select list make this query so slow ?

    Because a long nchar column drastically reduces the number of rows per data page, increases considerably...

  • RE: SQL question

    Tested and working:

    Select ListName

    FROM #tblParent As p

    Inner Join

    (

      Select ParentID, Count(Distinct CategoryCode) As CountAB

      From #tblChild

      WHERE CategoryCode in ('A','B')

      Group By ParentID

    ) dt

      On p.ID = dt.ParentID

    Where...

  • RE: Rolling SUM

    Select t1.ID, t1.Value,

      (Select Sum(t2.Value) From YourTable As t2

       Where t2.ID = t1.ID And t2.Identity <= t1.Identity 

       ) As Summed

    From YourTable As t1

  • RE: Rolling SUM

    Is there a 3rd column available in the original 2 column set that supplies the order in which the rows occur ?

     

  • RE: Help with update query

    Update P

    Set

      price = O.price

    From Products As P

    Inner Join Products_Options As OP

      On (OP.ProductID = P.ProductID)

    Inner Join Options As O

      On (O.OptionID = OP.OptionID And

            O.ProductID = OP.ProductID)

     

  • RE: Index on GUID column

    >>1. What will the drawbacks of having no Clustered index on a table? (for both static & transactional table)

    Table fragmentation. Maintenance utilities like DBCC DBREINDEX() will not be able to...

  • RE: Priming Select Count(*) into a variable

    DECLARE @y INT

    SELECT @y = COUNT(*)  FROM Customers

  • RE: Returning the first row for each group

    >>PW: is there any need for the following...

    >>dt.MaxCreatedPerGroup = tbl1.DateCreated

    It doesn't work without that. The purpose of the derived table is to find the most recent date per GroupID....

  • RE: Returning the first row for each group

    That "simple" query is too simple:

    group by groupID, groupValue

    You can't group on GroupValue, if the requirement is to eliminate all but 1 of the GroupValues for each...

  • RE: Returning the first row for each group

    Join to a derived table that gives you Max(Date) per group to join to:

    select tbl1.groupID, tbl1.groupValue, tbl1.dateCreated

    from tbl1

    Inner Join

    (

      Select GroupID, Max(DateCreated) As MaxCreatedPerGroup

      From tbl1

      Group By GroupID

    ) dt

     ...

  • RE: appending/joining result sets of subqueries

    Use derived tables instead of sub-queries

    Use joins instead of IN() for improved efficiency

    Use a UNION ALL for mutually exclusive resultsets, instead of an OR condition

     

    select distinct customer_id

    from orders As...

  • RE: TSQL optimize database

    A DBCC DBREINDEX would probably be useful. If the tables that are pulled in are essentially readonly for reporting purposes, you could DBREINDEX with a 100% fillfactor, which would reduce...

  • RE: Can I not use CREATE VIEW in a DTS package or sp?

    Syntax error in my delete code.

    DELETE ar

    FROM @tblARData As ar

    WHERE EXISTS (

      SELECT *

      FROM @tblARDataTemp As t

      WHERE t.Site = ar.Site

    )

Viewing 15 posts - 511 through 525 (of 1,347 total)