Forum Replies Created

Viewing 15 posts - 3,526 through 3,540 (of 4,085 total)

  • RE: case statement help.

    bass8117 (10/27/2011)


    below is part of code that includes many subselects, sums, etc. here's the problem I have,

    in the CHRG0.CHRG_AMT column I have a reverse charge of -289.00 with a CHRG0.CHRG_BAL...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Select top five rows for each key value

    Actually, I didn't read your query closely enough. I didn't see that you were using a subquery.

    The two approaches are equivalent and will give the exact same execution...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Help needed getting summary by weeks of current month

    Here is a fairly simple way to get what you're looking for.

    SELECT Year(ms.MonthStart), Datename(Month, MonthStart), WeekOfMonth, Sum(YourAmountField)

    FROM YourTable AS l

    CROSS APPLY ( SELECT DateAdd(Month, DateDiff(Month, 0, GetDate()), 0) AS MonthStart...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Retrieving status from history

    Depending on your indices and your data, the following may be more efficient.

    SELECT

    o.OrderID,

    ...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Select top five rows for each key value

    pschwartzbauer (10/26/2011)


    Can you use the RANK() function? Something like...

    SELECT A.Key, A.Date, A.Status, A.Ranking

    FROM (SELECT Key, Date, Status

    , RANK() OVER(PARTITION BY Key ORDER BY Date DESC) AS Ranking

    FROM table) A

    WHERE A.Ranking...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Ado recordset does not return value from varchar(MAX) field

    TEXT is being deprecated. Use varchar(max) instead.

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Left Command Troubles with NULL Values

    Ninja's_RGR'us (10/25/2011)


    Try LEFT(middlename + '.', 1) instead.

    That'll work depending on your concat_null_yields_null setting.

    You really should test before posting. I think what you wanted was actually

    ISNULL(LEFT(middlename, 1) + '.', '')

    This...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: index on big table

    dva2007 (10/25/2011)


    It doesnt have any unique key and the uniqey key is 70 character long.

    If it doesn't have a unique key, how are you able to determine it's length?

    If your...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Inserting a HTML Link Within the Cell of a Table in SQL Mail

    mpartridge (10/20/2011)


    The problem we have is with this line:

    td = '<a href="mailto:abc@xyz.com?Subject=Mailto%20Test&cc=xyz@abc.com">mailto:abc@xyz.com</a>', ''

    SQL will not recognise that as a HTML link and pastes the whole thing into a table cell,...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: How do I consolidate multiple rows into 1 row of output

    The typical way to do this is with FOR XML PATH. Most examples will also use a stuff to remove an initial extraneous delimiter, but I didn't include that...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Passing a Var to SP that needs B-up and

    Sean Lange (10/19/2011)


    Sure.

    declare @Codes varchar(25) = '14, 8, 21458'

    ;with cte(n) as (select 1

    union all select 14

    union all select 214

    union all select 314

    union all select 15

    union all select 8)

    select *

    from...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Passing a Var to SP that needs B-up and

    toddasd (10/19/2011)


    Here is a second option. Will not be as performant as the splitter option.

    Declare @Type_Code varchar(50)

    set @Type_Code = '4,11,12'

    Select * from table_Type_Codes Where @Type_Code like '%' + table_Type_Codes...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Join using Charindex -- there's got to be a better way?

    I would use LIKE instead. You'll probably still have to do an Index Scan (assuming that column is indexed on your claim table), but that will probably save you...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Non-aggregated in aggregate function

    There's another approach that edges out the CROSS APPLY approach. Depending on your indexes, this approach might be better.

    PARTITIONED AGGREGATE

    WITH OrdersRanked AS (

    SELECT [CustomerID],ShipVia

    , Sum(Freight) OVER( PARTITION BY CustomerID...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • RE: Creating a function to replace symbols with HTML names

    Lowell (10/18/2011)


    i had a ton of problems getting the function to paste cleanly into the forum, because it contains html codes, so here's a link to the text file of...

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

Viewing 15 posts - 3,526 through 3,540 (of 4,085 total)