Forum Replies Created

Viewing 15 posts - 3,031 through 3,045 (of 5,504 total)

  • RE: sorting

    I would probably use PATINDEX(). Something like

    DECLARE @search CHAR(2)

    SET @search='sm';

    WITH tab AS

    (

    SELECT 'Smith' AS lastname, 'John' AS firstname UNION ALL

    SELECT 'GoldSmith', 'Vincent' UNION ALL

    SELECT 'Smith', 'Patrick' UNION ALL

    SELECT 'Blacksmith',...

  • RE: Find the min and max effective date for when a value changed

    Would something along the following lines help you? (the "trick" is to build subgroups by contract_type as shown with the subgrp aliased column)

    ;

    WITH cte AS

    (

    SELECT

    *,

    ROW_NUMBER() OVER(ORDER BY...

  • RE: need to limit query criteria

    Please provide table def, sample data and expected result together with what you've tried so far. For details on how to post sample data please see the first link in...

  • RE: Can I use pivot on this query?

    But I don't think it's going to change the concept in general 😉

    It just leaves a little more work to do for the OP to modify the solution...

  • RE: Can I use pivot on this query?

    Chris Morris-439714 (8/6/2010)


    ...

    Chris, please take the time to set up the sample data properly. The whole batch should run without errors, and the column names and types must match those...

  • RE: Help Re-writting Query to remove SubQuery

    Matthew VanDerlofske-459596 (8/5/2010)


    Thank you for the explaination, that change has really made the difference, the query now runs on average less then 1 second which is well within acceptable limits.

    Thank...

  • RE: Help Re-writting Query to remove SubQuery

    Continuing my prev. post: You have an index lApprovalId and lItemId. Using the phone book example your index is sorted by last name (=lApprovalId) and first name (=lItemId).

    But your WHERE...

  • RE: Help Re-writting Query to remove SubQuery

    Matthew VanDerlofske-459596 (8/5/2010)


    Yeah sorry the sample data did not include any slots that would be picked up the the union, To get a data set that would get data from...

  • RE: Can I use pivot on this query?

    Ok, here's what I came up with so far:

    SELECT

    RP.PERIODNAME,

    [1.1] = COUNT(CASE WHEN C.CASETYPE = 'F' AND C.PROPERTYTYPE = 'P' AND RIGHT(C.IRN, 2) = 'PA' AND CE.EVENTNO = -16 AND MONTH(CE.EVENTDATE)...

  • RE: Help Re-writting Query to remove SubQuery

    Matthew, do you have an example that will actually trigger both parts of the UNION statement? With the data you provided I would suggest to delete the secon UNION part...

  • RE: Are the posted questions getting worse?

    GilaMonster (8/4/2010)


    Steve Jones - Editor (8/4/2010)


    We have that clock in the kitchen in our house. People think it's funny.

    My supervisor at the university has a very irritating clock. No numbers...

  • RE: Help Re-writting Query to remove SubQuery

    Hmm.... it seems like the execution plan got lost somewhere in between (2 bytes doesnt sound right...).

    Anyway. Step 1 would be to replace UNION with UNION ALL to eliminate a...

  • RE: Help Re-writting Query to remove SubQuery

    Matthew VanDerlofske-459596 (8/4/2010)


    LutzM, I implemented your suggestion, however running the query the old way and the your way resulted in the same duration (12 seconds with my test case).

    it seems...

  • RE: How to get the null column output

    Please provide table DDL and sample data.

    Based on what you've provided so far, I guess there a re some missing rows in your B cte.

    Hard to tell without sample data...

  • RE: Help Re-writting Query to remove SubQuery

    Changing the function into an inline-table valued function would also help, I guess...

    CREATE FUNCTION [DSUSER].[BDP_WPS_Approvals] (@lWPSID AS INT)

    RETURNS TABLE

    AS

    RETURN

    (SELECT

    (SELECT

    a.lUserID ID,

    a.lApprovalState...

Viewing 15 posts - 3,031 through 3,045 (of 5,504 total)