Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Nigel Wilson 945 posts 2077 karma points
    Jul 12, 2011 @ 23:24
    Nigel Wilson
    0

    Work around for "GROUP BY" SQL queries

    Hey

    I am simply posting this as it may help some who with their SQL queries when they want to use the "GROUP BY" option within their queries.

    The following query is valid in normal circumstances but when used within an XSLT file and the jesper plug-in it fails with the following error

    "An error occurred during a call to extension function 'SQLXml'. See InnerException for a complete description of the error... GROUP BY and aggregate functions are currently not supported with FOR XML AUTO... "

    SELECT 
    category, RecvdDate, count(callid) as dailyTotal 
    FROM 
    calllog 
    WHERE 
    category IN ('Hardware','Other Software','Wholesale Operations') AND 
    RecvdDate <= '2011-05-15' AND 
    RecvdDate >= '2011-04-17' 
    GROUP BY 
    category, RecvdDate
    ORDER BY category, RecvdDate

    To get around this you need to wrap the query with another SELECT statement as follows:

     

    SELECT outputTotals.category, outputTotals.RecvdDate, outputTotals.dailyTotal FROM 
        (
      SELECT 
    category, RecvdDate, count(callid) as dailyTotal 
    FROM 
    calllog 
    WHERE 
    category IN ('Hardware','Other Software','Wholesale Operations') AND 
    RecvdDate <= '2011-05-15' AND 
    RecvdDate >= '2011-04-17' 
    GROUP BY 
    category, RecvdDate
    ORDER BY category, RecvdDate ) AS outputTotals ORDER BY category, RecvdDate

    I hope this helps someone as I love using this great plug-in.

    Regards

    Nigel

     

     

  • Jesper Ordrup 1019 posts 1528 karma points MVP
    Jun 28, 2021 @ 15:13
    Jesper Ordrup
    0

    Did you solve this?

    Sorry for the delay :-)

Please Sign in or register to post replies

Write your reply to:

Draft