• realvilla (6/21/2013)


    Sean, you may not be there today but I made an interesting discovery. I tried four groupings for totals. For example, I took the group represented by:

    Select *

    From VehiclesToUpdate

    Where Region='Central' And ProgYear='13' And RiskNonriskFlag='R' And MFG = 'MIT' And LeaseCycle='1' And ModelName='LANCER'

    ...and I got 202 units. Then taking that same grouping I tried adding the UnitCount in the RetrunsPros. Guess what. 202 units. I tried this for three other groups and they all matched perfectly. Then I tried it for the total unit count and they didn't match, but that could be explained by the gap cars (source='G') I'm getting closer. I thought you would like to hear the good news.

    That is good news. Sounds like you are pretty close to having it figured out.

    _______________________________________________________________

    Need help? Help us help you.

    Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.

    Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.

    Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
    Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
    Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
    Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/