PIVOT query

  • Hi

    I have this query using PIVOT

    SELECT * FROM (

    SELECT

    a.Mun,

    l.Name,

    a.NumberOfRooms

    FROM Acco as a

    INNER JOIN look as l

    ON a.AccoTypeId = l.id

    INNER JOIN reg as r

    ON r.AccoId = a.Id

    WHERE r.RegDate IS NOT NULL AND r.RegDate <> '' and a.Mun like 'CB%'

    ) as t

    PIVOT(

    SUM(NumberOfRooms)

    FOR Name IN (

    [Hotel],

    [Inn],

    [Resort],

    [Motel],

    [Rented Room],

    [Unusual Lodgings],

    [Vacation Home],

    [Bed and Breakfasts],

    [Hostel],

    [Cottage, Cabin or Mini-home],

    [Other])

    ) AS pivot_table

    The output of this shows me NULL where the column is INN - however, there is value in the column , but some how shows me NULL..any suggestions on this query ? thanks

    Result seen as as below

    Result without using PIVOT: as seen there are  rooms!

     

     

     

     

  • Your field probably has a non-printable character in it such as a tab.  I'm comfortable enough with binary that I convert to binary to find problems like this.

    Drew

    J. Drew Allen
    Business Intelligence Analyst
    Philadelphia, PA

  • Thanks for replying back, I'll take a look at the suggestion

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply