Hello,
I have a simple inner join query that returns a happy set of results. It works great without GROUP BY clause as seen below. However when I add "GROUP BY" clause it returns nothing. I am trying to understand why. This is a query against a log table and currently there is only one entry for each CUSTOMER. in the log.
Any help would be greatly appreciated.
SELECT customer.id AS custid, custrate.crid, DLS_pbx_tenant.tenantid, DLS_pbx_tenant.mirror_exts FROM DLS_PBX_tenant, customer, custrate WHERE CONVERT(INTEGER, DLS_PBX_tenant.name) = customer.id AND CONVERT(INTEGER, DLS_PBX_tenant.name) = custrate.custid AND custrate.rgid = 540 AND dls_pbx_tenant.custid IN (39866) GROUP BY customer.id, custrate.crid, DLS_pbx_tenant.tenantid, DLS_pbx_tenant.mirror_extsResult:
+--------+-------+----------+-------------+ | custid | crid | tenantid | mirror_exts | +--------+-------+----------+-------------+ | 37769 | 44956 | 20 | 0 | | 37771 | 44960 | 38 | 0 | | 39304 | 48849 | 9 | 0 | | 39881 | 50525 | 7 | 1 | | 39882 | 50526 | 6 | 0 | | 39888 | 50555 | 54 | 0 | | 39903 | 50589 | 14 | 0 | | 39908 | 50595 | 16 | 0 | | 39911 | 50601 | 17 | 0 | | 39947 | 50695 | 24 | 0 | | 39961 | 50725 | 28 | 0 | | 39974 | 50767 | 35 | 0 | | 39982 | 50783 | 34 | 1 | | 40002 | 50852 | 37 | 0 | | 40012 | 50897 | 41 | 0 | | 40032 | 50945 | 49 | 0 | | 40034 | 50949 | 48 | 0 | | 40042 | 50977 | 55 | 0 | | 40048 | 50986 | 51 | 0 | | 40049 | 50987 | 52 | 0 | | 40064 | 51024 | 56 | 0 | | 40070 | 51037 | 57 | 1 | | 40073 | 51046 | 59 | 0 | +--------+-------+----------+-------------+