Forum Replies Created

Viewing 15 posts - 4,021 through 4,035 (of 4,085 total)

  • RE: How to calculate weighted averages

    Jon Beer (8/17/2009)


    Our formula is:

    (CompanyA avg_customer_revenue * CompanyA total_customers) + (CompanyB avg_customer_revenue * CompanyB total_customers)

    + (CompanyC avg_customer_revenue * CompanyC total_customers)

    / (CompanyB total_customers + CompanyC total_customers)

    In the denominator we...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Get products ordered by category order

    I think that you're trying to make this more complicated than it needs to be. I was able to match your output with a simple ORDER BY clause.

    SELECT Parent_ID,...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Select using mutiple tables including reference table

    netguykb (8/15/2009)


    I think its because FOR XML PATH is a 2005 thing I only have 2000

    [...]

    Thanks again I appreciate both your efforts, and he definitely pays to post with etiquette

    Well,...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Dynamic WHERE clause

    I think this code is much simpler.

    ALTER procedure Emp_name_proc

    (

    @emp_id varchar(100)

    )

    as

    begin

    declare @sql varchar(100)

    select @sql = 'SELECT EmpName FROM Test WHERE EmpID IN (' + @emp_id + ')'

    Exec( @sql )

    end

    No need for...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: checking for data exists in a multiple tables in single query

    Grant Fritchey (8/13/2009)


    Or, since you only care about when records do exist, check for NOT NULL values on the outer table. You'll still arrive at the same place.

    No, the OP...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: checking for data exists in a multiple tables in single query

    If you are using joins to check, an inner join will only work where a record exists. If you want to check for non-existence, you will have to use...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Just pull back the MAX Date

    Ryan Keast (8/13/2009)


    When I run this code I am getting three results for Sales Invoice Reference 4980586.

    I expect this as I am linking to the dbo.DW_SERVICEORDERSJOBS_F table and that invoice...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Select using mutiple tables including reference table

    Julie Zeien (8/12/2009)


    Correct me if I'm wrong. I'm not saying the OP shouldn't use the PIVOT solution. I'm just saying that if they wanted something that didn't care...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: How to insert data into table without cursor

    Here is another option using Row_Number() instead of the Identity Column. This means that you don't need the DDL language to create the temp table.

    Declare @TagNameIDBase int

    SELECT @TagNameID=isnull(MAX(TagNameID),0) from...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Insert a HTMl tag into a SQL server table column

    Lowell (8/12/2009)


    the forum doesn't like things that look like html tags....wierd results occur, like the clickable button above, which got rendered as an object instead of text:

    i had to find...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Select using mutiple tables including reference table

    Julie Zeien (8/12/2009)


    I don't have much experience using PIVOT, but I think Drew's solution will only work if each scout only has two parents.

    My solution will work for stepparents as...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Select using mutiple tables including reference table

    That's much better. Try the following code:

    SELECT SCT_NAME, [1] + IsNull(', ' + [2], '') AS Parents

    FROM (

    SELECT

    ...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: PIVOT problem : produces multiple lines

    alef (8/11/2009)


    I've tried the solution of SSCrazy Eights and this solution is perfect.

    Is there an explanation why your solution is working and mine not?

    I think that this line from BOL...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Select using mutiple tables including reference table

    You're going to need to use a PIVOT (or equivalent). If you want a more detailed answer, I suggest that you follow the forum etiquette guidelines and post the...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: find users that only have certain value

    The following query only queries #tmp once.

    WITH Z_cte AS (

    SELECT id FROM #tmp

    GROUP BY id

    HAVING Min(value) = 'Z'

    ...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

Viewing 15 posts - 4,021 through 4,035 (of 4,085 total)