Forum Replies Created

Viewing 15 posts - 3,601 through 3,615 (of 4,087 total)

  • RE: Negative number results

    It's doing integer division. 100/200 = 0.

    The simplest way to not use integer division is to multiply by a decimal or float value (such as 1.00) first.

    1.00 * 100/200...

  • RE: what component should I use ?

    You don't need the quotes. (In fact, I think the quotes cause problems.)

    Drew

  • RE: what component should I use ?

    Here is a sample of the batch file. You have to specify the server and database separately, so the IF statement is setting up different environment variables for each.

    if...

  • RE: UNION or other way to extract data?

    This will also give you the correct results. I suspect it might be more efficient than having the two separate subqueries, but haven't had a chance to test it.

    SELECT...

  • RE: what component should I use ?

    mw112009 (9/26/2011)


    Sir

    We have 6 servers and I have to deploy many stored procs in each of these servers. Doing them manually is a pain. Besides I run into situations where...

  • RE: UNION or other way to extract data?

    Your English statement of the criteria does not match the expected results. Transaction_IDs 1-8 all have an instance of Type A, so they should all be included in your...

  • RE: Multiple Records / Max Date with a Twist

    As I suggested earlier, you probably want to use a CTE with Row_Number()

    WITH POLineItems AS (

    SELECT A.OrdN03

    ...

  • RE: Using Case and NULL values

    You just need to use slightly different syntax.

    SELECT p.escProduct AS ep, count(*) as totEsc,

    CASE WHEN o.ocDateClosed IS NULL THEN

    avg(DATEDIFF(DAY, o.ocDateOpened, GETDATE()))

    ELSE avg(DATEDIFF(DAY, o.ocDateOpened, o.ocDateClosed))

    End AS 'srAge'

    FROM tblocMain o INNER JOIN...

  • RE: Needed help to convert column as row values

    What you're asking to do violates basic principles of database design. Why do you need to do this?

    Drew

  • RE: date time format conversion

    HowardW (9/22/2011)I also fundamentally disagree that the purpose of documentation isn't to be accurate.

    No one said that it wasn't the goal. What I was trying to say is that...

  • RE: Count with Group By clause

    This should give you what you need. It's not tested.

    SELECT OrgID, Count(IndID)

    FROM Individuals AS i

    CROSS APPLY(

    SELECT TOP (1) OrgID

    FROM Transactions AS t

    WHERE t.IndID = i.IndID

    ORDER BY TranID

    ) AS t

    GROUP...

  • RE: Multiple Records / Max Date with a Twist

    You don't need to supply a real datetime for the 99999999. Min() and Max() will only return NULL if all of the values are NULL, but that's what you...

  • RE: Joining, but need to find the row with the min values in it

    With appropriate indices, a CROSS/OUTER APPLY should perform better, but you should test it with your actual data. An OUTER APPLY corresponds to the LEFT JOIN that you are...

  • RE: date time format conversion

    HowardW (9/21/2011)

    Maybe I'm misreading, or is this a mistake in BOL? (you'd think not for the amount this article is used)

    Manuals are not technical specs nor are they gospel. ...

  • RE: Subquery returned more than 1 value.

    duanecwilson (9/21/2011)


    I had been working on a larger query that surrounded this one

    In that case, you might consider using a CROSS APPLY instead of Max().

    SELECT DayKey, Port_ID

    FROM <<Main Query>>

    CROSS APPLY...

Viewing 15 posts - 3,601 through 3,615 (of 4,087 total)