MapInfo Pro

 View Only
  • 1.  Cannot Run Summary Query on Pen Style

    Posted 05-21-2025 19:27
    Help?!
    Can anyone tell me why this runs fine...
    But when I try to summarize the results, it fails?
    Thanks,
    -- Steve Wallace


    ------------------------------
    Steve Wallace
    Florida Farm Bureau Insurance
    ------------------------------


  • 2.  RE: Cannot Run Summary Query on Pen Style

    Posted 05-21-2025 21:48

    Hi Steve,

    If you are selecting a column that is not listed as a group by column, you need to use an aggregate function e.g. Max().  These are available from the Aggregates drop-down in the SQL Select Dialogue.  However, using an aggregate on ObjectInfo(obj,2), which returns a Pen Style, is not realistic and generates an error.  You might need to use StyleAttr to extract specific attributes from the Pen Style:

    So the two changes you require are:

    1. Include col1 in your Select clause
    2. Use an aggregate plus StyleAttr for selecting the Pen Style attributes

    E.g.

    SELECT col1, Max(StyleAttr(ObjectInfo(obj,2), 5)) "Pen_Pattern_Index", Count(*) "RecCnt"

    FROM FL_Legacy_Territory_DF

    GROUP BY col1



    ------------------------------
    James Nolet
    GIS Manager
    CAF Consulting
    Melbourne office, VIC, Australia
    ------------------------------



  • 3.  RE: Cannot Run Summary Query on Pen Style

    Employee
    Posted 05-22-2025 01:15

    MapInfo Pro sometimes gets confused when using a function that can return multiple types.

    I always recommend wrapping such a function call in a "converter" function to state the type you expect back clearly.

    In your example, you can use the Str$() function to cast the returned value to a string:

    Str$(ObjectInfo(obj,2)) 

    In other cases, you would use the Val() function to cast it to a numeric value.

    SELECT Str$(ObjectInfo(obj,2)) "Pen_Pattern", Count(*) "RecCnt"
    FROM FL_Legacy_Territory_DF
    GROUP BY col1


    ------------------------------
    Peter Horsbøll Møller
    Principal Presales Consultant | Distinguished Engineer
    Precisely | Trust in Data
    ------------------------------