Forum Replies Created

Viewing 15 posts - 916 through 930 (of 1,228 total)

  • RE: need help getting sum and grouping right...

    You might want to rewrite it to make it more readable and five times faster:

    SELECT

    PATID,

    CARRIER_ID,

    DateRange,

    [BAL] = SUM(BAL)

    FROM (

    SELECT ...


    [font="Arial"]Low-hanging fruit picker and defender of the moggies[/font]

    For better assistance in answering your questions, please read this[/url].


    Understanding and using APPLY, (I)[/url] and (II)[/url] Paul White[/url]

    Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]

  • RE: need help getting sum and grouping right...

    Let's have a look at a single one of those date-range specific queries:

    SELECT ...


    [font="Arial"]Low-hanging fruit picker and defender of the moggies[/font]

    For better assistance in answering your questions, please read this[/url].


    Understanding and using APPLY, (I)[/url] and (II)[/url] Paul White[/url]

    Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]

  • RE: need help getting sum and grouping right...

    jrbass81 (4/20/2011)


    Lets try this way...below is my code and a few results....I need to get the results to only list on ins company and there total and not 5 BCBSNC...


    [font="Arial"]Low-hanging fruit picker and defender of the moggies[/font]

    For better assistance in answering your questions, please read this[/url].


    Understanding and using APPLY, (I)[/url] and (II)[/url] Paul White[/url]

    Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]

  • RE: need help getting sum and grouping right...

    jrbass81 (4/20/2011)


    I need the following listed where ins company carrier ID is only listed once and the total for each is only listed once. I hope that makes sense...

    SEE ATTACHMENTS

    Read...


    [font="Arial"]Low-hanging fruit picker and defender of the moggies[/font]

    For better assistance in answering your questions, please read this[/url].


    Understanding and using APPLY, (I)[/url] and (II)[/url] Paul White[/url]

    Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]

  • RE: Query for reome Duplcate row

    shubham.saxena67 (4/20/2011)


    ...in this data will be in following form:

    Adm_no FirstName Last_name Session Class

    01/742 NIKHIL SINGH 2010 - 2011 VIII

    01/742 ASHISH SINGH 2011 - 2012 IX

    01/743 ANSHIKA GUPTA 2011 - 2012...


    [font="Arial"]Low-hanging fruit picker and defender of the moggies[/font]

    For better assistance in answering your questions, please read this[/url].


    Understanding and using APPLY, (I)[/url] and (II)[/url] Paul White[/url]

    Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]

  • RE: Using SUM renders too many records

    Going back to your earlier post,

    sum(bp.gross_quantity / 42.0) as qty_gross,sum(bp.net_quantity / 42.0) as net_qty

    FROM [VEMA-FACS1].FUELFACS.dbo.bulk_movement AS bm

    INNER JOIN...


    [font="Arial"]Low-hanging fruit picker and defender of the moggies[/font]

    For better assistance in answering your questions, please read this[/url].


    Understanding and using APPLY, (I)[/url] and (II)[/url] Paul White[/url]

    Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]

  • RE: Select Query

    Research PIVOT.


    [font="Arial"]Low-hanging fruit picker and defender of the moggies[/font]

    For better assistance in answering your questions, please read this[/url].


    Understanding and using APPLY, (I)[/url] and (II)[/url] Paul White[/url]

    Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]

  • RE: Return 0 From Function

    david.holley (4/20/2011)


    I created the following function to pull the min or max date from a table of dates. It does work. However, if it does not find a record, it...


    [font="Arial"]Low-hanging fruit picker and defender of the moggies[/font]

    For better assistance in answering your questions, please read this[/url].


    Understanding and using APPLY, (I)[/url] and (II)[/url] Paul White[/url]

    Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]

  • RE: Need to insert Reocrds in uniqueidentifier column

    It doesn't work because '00000000-0000-0000-000-0000000000' won't cast to a uniqueidentifier. Try this:

    SELECT CAST('00000000-0000-0000-000-0000000000' AS uniqueidentifier)

    SELECT CAST('00000000-0000-0000-0000-000000000000' AS uniqueidentifier)

    Why do you want to put this value into a uniqueidentifier column? Why...


    [font="Arial"]Low-hanging fruit picker and defender of the moggies[/font]

    For better assistance in answering your questions, please read this[/url].


    Understanding and using APPLY, (I)[/url] and (II)[/url] Paul White[/url]

    Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]

  • RE: Are the posted questions getting worse?

    Craig Farrell (4/19/2011)


    Brandie Tarvin (4/19/2011)


    I'm going to violate the rule and add a "technical" question to The Thread under the caveat that I don't really need an answer for a...


    [font="Arial"]Low-hanging fruit picker and defender of the moggies[/font]

    For better assistance in answering your questions, please read this[/url].


    Understanding and using APPLY, (I)[/url] and (II)[/url] Paul White[/url]

    Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]

  • RE: Using SUM renders too many records

    Hi

    Is this issue resolved now?

    If not, there are a couple of lines of enquiry to follow;

    Check if bp.movement_number = 2191 appears in rows other than those where bm.bulk_movement_id IN ('54332','54355','54356')....


    [font="Arial"]Low-hanging fruit picker and defender of the moggies[/font]

    For better assistance in answering your questions, please read this[/url].


    Understanding and using APPLY, (I)[/url] and (II)[/url] Paul White[/url]

    Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]

  • RE: Using SUM renders too many records

    snufse1 (4/19/2011)


    I commented out all joins except for

    FROM[VEMA-FACS1].FUELFACS.dbo.bulk_movement AS bm

    INNER JOIN[VEMA-FACS1].FUELFACS.dbo.bulk_product AS bp ON bp.bulk_movement_id = bm.bulk_movement_id

    and result is (same as before)

    201103302011 MC 01 497883100 859700...


    [font="Arial"]Low-hanging fruit picker and defender of the moggies[/font]

    For better assistance in answering your questions, please read this[/url].


    Understanding and using APPLY, (I)[/url] and (II)[/url] Paul White[/url]

    Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]

  • RE: Inserting Incremented Alphabets into a column

    LOL Wayne that was quick!

    ;WITH VendorCodes AS

    (

    SELECT [letter] = CHAR(64 + rn)

    FROM (SELECT rn = ROW_NUMBER() OVER(ORDER BY [Name]) FROM sys.columns

    ) d WHERE rn < 27

    )

    SELECT c1.letter, c2.letter

    FROM VendorCodes...


    [font="Arial"]Low-hanging fruit picker and defender of the moggies[/font]

    For better assistance in answering your questions, please read this[/url].


    Understanding and using APPLY, (I)[/url] and (II)[/url] Paul White[/url]

    Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]

  • RE: Inserting Incremented Alphabets into a column

    kr.nithin (4/19/2011)


    Yep In spite of the Numeric Primary Key. We need 2 character Vendor Code for each vendor.

    How many vendors do you currently have? What is the rate at which...


    [font="Arial"]Low-hanging fruit picker and defender of the moggies[/font]

    For better assistance in answering your questions, please read this[/url].


    Understanding and using APPLY, (I)[/url] and (II)[/url] Paul White[/url]

    Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]

  • RE: Help with Query

    Bob

    Have a look at the output from this:

    CREATE TABLE #Test ([Response ID] INT, Company VARCHAR(15), Amount MONEY, [Quarter] INT, [Year] INT)

    INSERT INTO #Test ([Response ID], Company, Amount, [Quarter], [Year])

    SELECT...


    [font="Arial"]Low-hanging fruit picker and defender of the moggies[/font]

    For better assistance in answering your questions, please read this[/url].


    Understanding and using APPLY, (I)[/url] and (II)[/url] Paul White[/url]

    Hidden RBAR: Triangular Joins[/url] / The "Numbers" or "Tally" Table: What it is and how it replaces a loop[/url] Jeff Moden[/url]

Viewing 15 posts - 916 through 930 (of 1,228 total)