Forum Replies Created

Viewing 15 posts - 2,431 through 2,445 (of 4,085 total)

  • RE: get the price of last buy of each sell

    Why aren't the last buys from 2016-08-18 17:38:40.000 and 2016-08-17 15:03:52.000?

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Check if both fields from table B are in table A

    Francis Twomey (8/22/2016)


    Thanks for the responses. Here is my code currently:

    INSERT INTO item_relation_table

    (parent__id,

    child__id,

    relation)

    SELECT xm.1_id, xm.2_ID,

    'A',

    from tablexm xm

    where xm.1_id != xm.2_ID and

    exists(select 1 from item ip WHERE ip.mfg =...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Need Guidance On Query

    Depending on what your statuses are, you may not even need a case expression. If your only statuses are ADD and DISCHARGE, then you can just use MAX(status) <...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Need Guidance On Query

    Jacob Wilkins (8/22/2016)


    drew.allen (8/22/2016)


    COUNT will work as an aggregate if you return a NULL in the proper cases. COUNT() may not perform the best, but it will work.

    COUNT(CASE WHEN...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Need Guidance On Query

    COUNT will work as an aggregate if you return a NULL in the proper cases. COUNT() may not perform the best, but it will work.

    COUNT(CASE WHEN status='Discharge' THEN 1...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Check if both fields from table B are in table A

    You should post what you've already tried. It's going to be easier for you to understand if it's just a minor change in your existing code rather than having...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: stored procedure issue

    Jacob Wilkins (8/22/2016)


    Something like this:

    [column] LIKE '['+@a+'-'+@b+']%'

    Cheers!

    This will only work if you pass in single characters as your parameters. Given that you've defined your parameters as VARCHAR(50), it seems...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: stored procedure issue

    And if you're looking for a range of values between the two parameters, it becomes a bit tricky. For instance, if your parameter values are 'A' and 'C', you'll...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Are the posted questions getting worse?

    WayneS (8/22/2016)


    drew.allen (8/17/2016)


    I'm writing an article explaining my solution to Credits and Debits and am looking for two or three people to review it before I submit it. Any...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Re-ordering a Sequence

    mister.magoo (8/21/2016)


    How is this not just a simple update/cte?

    WITH CTE AS

    (

    SELECT

    seq

    , ROW_NUMBER() OVER

    (

    ...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Selective updates to NULL

    This will also work.

    UPDATE #test

    SET Flag = @Flag

    WHERE Id = @Id

    AND COALESCE(Flag, ~@Flag, 0) <> COALESCE(@Flag,...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Selective updates to NULL

    ChrisM@Work (8/19/2016)


    Why can't you use this, Phil (substituting "peanut" for an appropriate integer value):

    UPDATE #test

    SET Flag = @Flag

    WHERE Id =...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Selective updates to NULL

    I like the following method, particularly when you are comparing multiple columns.

    UPDATE #test

    SET Flag = @Flag

    CROSS APPLY (

    SELECT Flag

    ...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: WHERE clause problem comparing 2 float values

    This is even in the Microsoft documentation.

    Using decimal, float, and real Data


    Avoid using float or real columns in WHERE clause search conditions, especially the = and <> operators. It is...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: selecting top rows by counting a variable total

    Sorry, I didn't realize that you were on SQL 2005. You need SQL 2012 to use this construct. I should pay more attention to which forum I'm in.

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

Viewing 15 posts - 2,431 through 2,445 (of 4,085 total)