Grouping Results

What I need to do, is the following:

For ProjState, if it has a value of PS/Client or S/Disc, I need that to be displayed and groups as PS/Client, but cannot change the values within the table.  Can I do this in code?
SELECT DISTINCT Count(*) AS HeadCount, Forecast.PrimaryRole, Forecast.Category, Forecast.ProjState
FROM Forecast
WHERE (Category="IMSP" And ProjState="P") And PrimaryRole Is Not Null Or (Category="IMSC" And ProjState="D") And PrimaryRole Is Not Null Or (Category="IMSC" And ProjState In ("PS/Client","S/Disc") And PrimaryRole Is Not Null)
GROUP BY Forecast.Category, Forecast.ProjState, Forecast.PrimaryRole;

Open in new window

LVL 5
tobey1Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ashish PatelCommented:
SELECT DISTINCT Count(*) AS HeadCount, Forecast.PrimaryRole, Forecast.Category, IIF(Forecast.ProjState = "PS/Client" or Forecast.ProjState = "S/Disc", "PS/Client", Forecast.ProjState) as ProjState
FROM Forecast
WHERE (Category="IMSP" And ProjState="P") And PrimaryRole Is Not Null Or (Category="IMSC" And ProjState="D") And PrimaryRole Is Not Null Or (Category="IMSC" And ProjState In ("PS/Client","S/Disc") And PrimaryRole Is Not Null)
GROUP BY Forecast.Category, Forecast.ProjState, Forecast.PrimaryRole;
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
JimFiveCommented:
Yes. Like so:

SELECT DISTINCT Count(*) AS HeadCount, Forecast.PrimaryRole, Forecast.Category, CASE WHEN Forecast.ProjState = 'S/Disc' THEN 'PS/Client' ELSE Forecast.ProjState END as ProjState
FROM Forecast
WHERE (Category="IMSP" And ProjState="P") And PrimaryRole Is Not Null Or (Category="IMSC" And ProjState="D") And PrimaryRole Is Not Null Or (Category="IMSC" And ProjState In ("PS/Client","S/Disc") And PrimaryRole Is Not Null)
GROUP BY Forecast.Category,CASE WHEN Forecast.ProjState = 'S/Disc' THEN 'PS/Client' ELSE Forecast.ProjState END as ProjState
, Forecast.PrimaryRole;
 
0
JimFiveCommented:
Slight Change, Thought this was SQL.  Use this for access

SELECT DISTINCT Count(*) AS HeadCount, Forecast.PrimaryRole, Forecast.Category, iif(Forecast.ProjState = "S/Disc","PS/Client",Forecast.ProjState) as ProjState
FROM Forecast
WHERE (Category="IMSP" And ProjState="P") And PrimaryRole Is Not Null Or (Category="IMSC" And ProjState="D") And PrimaryRole Is Not Null Or (Category="IMSC" And ProjState In ("PS/Client","S/Disc") And PrimaryRole Is Not Null)
GROUP BY Forecast.Category, iif(Forecast.ProjState = "S/Disc","PS/Client",Forecast.ProjState), Forecast.PrimaryRole;
0
tobey1Author Commented:
OK, great...that works for the display, but when I go to use the report, it still shows the S/Disc, should it have pulled the results into the Report, and not kept them as S/Disc?  How can I make the adjustment there?
0
JimFiveCommented:
Check your recordsource for the report and change that.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Query Syntax

From novice to tech pro — start learning today.