Link to home
Start Free TrialLog in
Avatar of Candidochris
CandidochrisFlag for United States of America

asked on

GROUP BY WITH CUBE Issue

I am having a problem with a query in SQL Server 2008R2.

 
SELECT T0.CardCode, T2.ItmsGrpNam
FROM OITM T0
INNER JOIN OITB T2 ON T0.ItmsGrpCod=T2.ItmsGrpCod
GROUP BY  T0.CardCode, T2.ItmsGrpNam  WITH CUBE

Open in new window


It yields this result set that looks like this:

CardCode | ItmsGrpNam
BrandX     | BrandX A
 (NULL)    |  BrandX A
BrandX     | BrandX B
 (NULL)    |  BrandX B

I am trying to get this result set:

CardCode | ItmsGrpNam
BrandX     | BrandX A
BrandX     |  BrandX B

OR this one:

CardCode | ItmsGrpNam
BrandX     | BrandX A
(NULL)      |  BrandX B

Can someone show me how to properly structure this query to achieve the desired result? Thanks.


ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial