Forum Replies Created

Viewing 15 posts - 346 through 360 (of 518 total)

  • RE: Delete Query

    This should work, I think..:

    DELETE D FROM Table1 AS D

    INNER JOIN StoreGroupMember A

    ON A.Store_ID = D.Store_ID

    WHERE A.StoreNumber = 9833

    I think I got the tables right, but it's a bit unclear....

  • RE: Finding the two highest values for a criteria

    WayneS (9/15/2010)


    Derrick Smith (9/15/2010)


    You mean you want to pull the two most recent orders for each product, sorted by OrderDate, and then display the corresponding OrderNumber, right?

    FelixG (9/15/2010)


    I need to...

  • RE: create db dynamically

    I suppose you could just create a dynamic sql statement to create the database with the company name as a variable, and execute that.

  • RE: Finding the two highest values for a criteria

    Sorry, misunderstood...try this. Will pull the two highest dates for each product, and print their corresponding order number.

    ;WITH CTE AS (

    SELECT ProductCode,

    ROW_NUMBER() OVER (PARTITION BY ProductCode ORDER BY OrderDate DESC)...

  • RE: Finding the two highest values for a criteria

    WITH CTE AS (

    SELECT ProductCode, MAX(OrderDate) as OrderDate, MAX(OrderNumber) as OrderNumber

    FROM Orders

    GROUP BY ProductCode

    )

    SELECT O.ProductCode, cte.OrderDate as [MaxOrderDate], cte.OrderNumber as [MaxOrderNumber]

    FROM Orders O

    INNER JOIN CTE on CTE.ProductCode = O.ProductCode

    I wasn't...

  • RE: i'm having a brain fart today

    edit: there are a few syntax issues with your script, such as cartesian products when you select multiple tables without any join criteria.

    Here is a script I've been using for...

  • RE: INNER JOIN CHALLENGE

    SELECT distinct MA.Account

    , M.DisplayName

    , MUA.UserName

    , CC.EmailTo

    , aspnet_Roles1.RoleName

    FROM AfsDepositGateway.dbo.MerchantAccounts MA

    INNER JOIN Merchants M ON

    M.MerchantId = MA.MerchantId

    INNER JOIN MerchantUserAccounts MUA ON

    MUA.MerchantId = M.MerchantID

    INNER JOIN CustomerContacts CC ON

    CC.CustomerContactId = M.CustomerContactId

    INNER...

  • RE: INNER JOIN CHALLENGE

    Ah crap, I did. Didn't even notice that. Hard to follow the logic of this query..working on it.

  • RE: INNER JOIN CHALLENGE

    Unfortunately I'm writing this blind with no real way to quickly check syntax..if you could post table definitions, it would help a bunch.

  • RE: INNER JOIN CHALLENGE

    As Mike said, if you create an alias for a table, you need to use that alias for every mention of the table. You can't mix and match. Also, I...

  • RE: Log and Data placement on a SAN.

    Yes, each instance needs its own IP address on a cluster.

    Also Yes, having the data files and log files on separate spindles is absolutely the best way to go.

  • RE: UPDATE statement

    Whoops - you're doing a cartesian join on your subqueries. It should be an inner join on those 3 fields. Haven't had my coffee yet...will update with a new query...

  • RE: index issue

    Just out of curiosity..have you run a dbcc dbreindex() or alter index rebuild? Also make sure you update statistics with fullscan after creating/dropping/modifying indexes.

  • RE: UPDATE statement

    You're missing a comma after the first subquery:

    and test_id = kc.test_id),

    district_average_percent = (SELECT district_average_percent

    If that doesn't resolve it, then you're probably getting more than 1 result from one of the...

  • RE: Logical Scan Fragmentation - Does it matter?

    Bhuvnesh (9/15/2010)


    Derrick Smith (9/14/2010)


    It sounds more like Table 2 is missing indexes or statistics.

    How did you get this from above first post ( from DBCC results)?

    Because there aren't many...

Viewing 15 posts - 346 through 360 (of 518 total)