Quantcast
Channel: Teradata Forums - All forums
Viewing all articles
Browse latest Browse all 27759

SELECT Failed 3504: Selected non-aggregate values must be part of the associated group - response (1) by dnoeth

$
0
0

In the Derived Table there's a GROUP BY missing while the outer query groups by too many columns.
And it seems you don't need to nest at all, this should return the same result:

SELECT
   COUNT (MB.MB_JOIN_KEY) MEM_COUNT,
   CASE WHEN MB.EFF_BEG_DT >= '2009/01/01' AND MB.EFF_END_DT <= '2009/01/31' THEN 'YES' ELSE 'NO' END AS P1_MBRMTH
FROM MB_TABLE MB
WHERE (MB.EFF_BEG_DT >= '2009/01/01' AND MB.EFF_END_DT <= '2009/01/31') OR
(MB.EFF_BEG_DT >= '2009/03/01' AND MB.EFF_END_DT <= '2009/04/30')
)MMM_MB
GROUP BY P1_MBRMTH

Dieter


Viewing all articles
Browse latest Browse all 27759

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>