[Webinar] Streamline your web hosting managementRegister Today

x
?
Solved

Grouping Results

Posted on 2008-01-31
5
Medium Priority
?
181 Views
Last Modified: 2010-03-20
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

0
Comment
Question by:tobey1
  • 3
5 Comments
 
LVL 23

Accepted Solution

by:
Ashish Patel earned 200 total points
ID: 20789895
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
 
LVL 15

Expert Comment

by:JimFive
ID: 20789908
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
 
LVL 15

Assisted Solution

by:JimFive
JimFive earned 200 total points
ID: 20789925
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
 
LVL 5

Author Comment

by:tobey1
ID: 20789974
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
 
LVL 15

Expert Comment

by:JimFive
ID: 20790051
Check your recordsource for the report and change that.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This post looks at MongoDB and MySQL, and covers high-level MongoDB strengths, weaknesses, features, and uses from the perspective of an SQL user.
Sometimes MS breaks things just for fun... In Access 2003, only the maximum allowable SQL string length could cause problems as you built a recordset. Now, when using string data in a WHERE clause, the 'identifier' maximum is 128 characters. So, …
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
The Relationships Diagram is a good way to get an overall view of what a database is keeping track of. It is also where relationships are defined. A relationship specifies how two tables connect to each other. As you build tables in Microsoft Ac…
Suggested Courses

612 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question