Has Group By been added to editor?

Has Group By been added to editor?

davidjmorindavidjmorin Posts: 101Questions: 31Answers: 0

I need to group some of my table data. I read back in 2017 it was not available. Has this been implemented? I need to group my notes by note_id so it will show all notes for that ID.

Thanks

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,172Questions: 26Answers: 4,923

    Is the RowGroup Extension what you are looking for?

    Kevin

  • davidjmorindavidjmorin Posts: 101Questions: 31Answers: 0
    edited August 2020

    @kthorngren

    This is what im trying to convert

    $sql = 'SELECT
    x.Invoice_  ,
    x.Tracking_,
    x.Qty,
    x.Product_SKU,
    x.Product_Name,
    x.Unit_Rebate,
    x.Related_Product,
    x.Related_SKU,
    x.Related_SN,
    x.Related_Cost,
    x.Related_Price,
    x.Rate_Plan,
    x.Customer,
    x.Sales_Person,
    x.Sales_Person_ID,
    x.Sold_On,
    x.Invoiced_At,
    x.Contract_,
    x.SOC_Code,
    x.Port_Number,
    x.Region,
    x.District,
    x.Vendor_Account_Name,
    x.ID,
    w.notes
    FROM (
           SELECT
           RQ.Invoice_  ,
           RQ.Tracking_,
           RQ.Qty,
           RQ.Product_SKU,
           RQ.Product_Name,
           RQ.Unit_Rebate,
           RQ.Related_Product,
           RQ.Related_SKU,
           RQ.Related_SN,
           RQ.Related_Cost,
           RQ.Related_Price,
           RQ.Rate_Plan,
           RQ.Customer,
           RQ.Sales_Person,
           RQ.Sales_Person_ID,
           RQ.Sold_On,
           RQ.Invoiced_At,
           RQ.Contract_,
           RQ.SOC_Code,
           RQ.Port_Number,
           RQ.Region,
           RQ.District,
           RQ.Vendor_Account_Name,
           RQ.ID
    FROM disc_rq_activations RQ
    LEFT JOIN
       disc_Activations VZ
       ON FIND_IN_SET(SUBSTRING(RQ.Related_SN,1, 13), SUBSTRING(VZ.Device_ID, 1,13))
       #ON IF(length(Related_SN) = 15,FIND_IN_SET(LEFT(Related_SN, length(Related_SN) - 1), VZ.Device_ID),Related_SN)
    WHERE
       VZ.Device_ID IS NULL
       AND RQ.District = "'.$region.'"
       AND STR_TO_DATE(RQ.Sold_On, "%b %e, %Y %l:%i %p")  BETWEEN "'.$mindate.'" AND "'.$maxdate.'"
       AND RQ.Product_Name != "ISPU Activation"
       AND RQ.Product_Name != "ISPU New Act"
       GROUP BY RQ.Tracking_, RQ.Related_SN
    
    ) as x
    LEFT JOIN (
       SELECT n.note_id, LEFT(n.modified,16) as modified, n.user,
              GROUP_CONCAT(n.note, " - (Checked By: ", n.user, ")" ORDER BY n.note_id separator "<br \>") as notes
       FROM daily_notes n
       GROUP BY n.note_id
    ) AS w
       ON w.note_id = x.ID
    

    specifically the GROUP BY n.note_id

  • allanallan Posts: 63,213Questions: 1Answers: 10,415 Site admin
    Answer ✓

    No it hasn't I'm afraid. For an SQL statement as complex as the one you have there, you'd need to make use of a VIEW. See this example.

    Allan

This discussion has been closed.