473,765 Members | 1,969 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Access 2007. Sql query

42 New Member
Hi everybody , I have this query in SQL using Access 2007:

Expand|Select|Wrap|Line Numbers
  1.  
  2. SELECT Count(Opportunities.Won) AS CountOfWon, Count(Opportunities.Lost) AS CountOfLost, Count(Opportunities.[Cancelled/Postponed]) AS [CountOfCancelled/Postponed], Opportunities.System
  3. FROM Opportunities
  4. WHERE ((("Opportunities.Won")=True)) OR ((("Opportunities.Lost")=True)) OR ((("Opportunities.[Cancelled/Postponed]")=True))
  5. GROUP BY Opportunities.System;
  6.  
  7.  
The problem is i get identical values for the three fields CountOfWon, CountOfLost, CountOfCancelle d/Postponed.

Please what to do?
Mar 26 '08 #1
2 1680
MikeTheBike
639 Recognized Expert Contributor
Hi

I assume all the feilds are yes/no, if so then perhaps this will give what you want, ie. the total of all 'Yes' values for each category?

SELECT Sum(IIF(Opportu nities.Won,1,0) ) AS CountOfWon, Sum(IIF(Opportu nities.Lost,1,0 )) AS CountOfLost, Sum(IIF(Opportu nities.[Cancelled/Postponed],1,0)) AS [CountOfCancelle d/Postponed], Opportunities.S ystem
FROM Opportunities
WHERE ((("Opportuniti es.Won")=True)) OR ((("Opportuniti es.Lost")=True) ) OR ((("Opportuniti es.[Cancelled/Postponed]")=True))
GROUP BY Opportunities.S ystem;


??


MTB
Mar 26 '08 #2
Sport Girl
42 New Member
Thank u Mike u r the best
Mar 26 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
4789
by: Andrew Tatum | last post by:
I have the following procedure that works great when I run it from SQL Server Manager. EXEC prGetReferrerPayroll @startdate, @enddate, @totalsignups, @totalopts. All I do is replace the variables with actual dates... EXEC prGetReferrerPayroll '02/01/2007 12:00 AM', '02/14/2007 11:59 PM', '01/01/2007 12:00 AM', '01/01/2007 12:00 AM'
2
2199
by: jafastinger | last post by:
I have a large union. If I break it into its individual parts they all run quick. The longest is the last select it takes 2 minutes to fetch all rows. When I run the query below it does not come back for quite some time. 20 minutes. There are very few duplicates. When I run the sql's individually the first two give no warning but the third does(SQL0437W Performance of this complex query may be sub-optimal. Reason code:"1". ...
3
7772
by: mnjkahn via AccessMonster.com | last post by:
I'm running Access 2003, modifying a query that has over 45 fields. When I right click on the field name in Query Design View, and then click Build, Access crashes before the Build window appears. It doesn't happen every time, and using the Zoom window works fine. It appears that it only happens when I want to modify an existing expression. This continues to happen even after the database is repaired and reopened. Anyone have any...
0
1285
by: fiff | last post by:
Hi, I need help with query. I have access log table something like this: session_id (int) | user (varchar) | login_time (datetime) | logout_time (datetime) 1 | JOHN | 2007-03-02 15:32:01 | 2007-03-02 18:01:55 2 | JOHN | 2007-03-09 11:43:33 | 2007-03-09 21:02:25 3 | JOHN | 2007-03-15 22:00:05 | 2007-03-16 06:37:21 4 | MIKE | 2007-04-02 12:32:01 | 2007-03-02 14:01:55 5 | MIKE | 2007-03-09 10:41:33 | 2007-03-09 20:44:15
1
4110
by: bobykim | last post by:
Hi All, I'm using MS Access 2003 in a Windows XP environment. I've created an aging report for my department that is based on what I call the "Main query" with an IIf statement that allows the user to define the dates into 30 day aging segments. Then I've created a crosstab query which counts the results. How I'd like the report to appear is like this: Entity_Type | 1 to 30 days | 31 to 60 days | Over 60 days OPFACT ...
1
4713
by: rickcross | last post by:
I am trying to use the Access 2007 runtime. I have a program that is fully working in 2007 but when I install the runtime version with same Operating system and Access 2003 installed I have multiple errors. One error "Function is not available in table level validation expression." This error occurs three times. when I have a two part delete query or a lookup function that checks for a duplicate entry and a update query that adds a...
8
7172
by: elias.farah | last post by:
Hello Everyone, I'm having some very weird behavior on a couple of Access forms. (Not all forms, just some of them). The forms have been working for years, under Access XP/2003 etc, and last week upgraded from Windows XP/Office 2003 to Vista x64/Office 2007. Under Access 2007, a couple of forms are now taking 60 seconds to
4
2395
by: myemail.an | last post by:
Hi all, I use Access 2007 and have the following problems: when exporting banal select queries (either to Excel or to a csv file) I find that exporting often doesn't work and creates a file with the WHOLE dataset, i.e. including those rows which the criteria of the query excluded. For example: let's say I have a database with sales by region. I create a select query to only show sales from Europe. The query runs
10
4575
by: Arno R | last post by:
Hi all, So I bought a new laptop 10 days ago to test my apps with Vista. (home premium) Apparently Office 2007 is pre-installed. (a time limited but complete test version, no SP1) So I take the opportunity to test some new features of Access2007 before actually 'stepping over'. First thing that troubles me of course is 'the ribbon', but my question now is about speed. I opened one of my Access 2000-apps in Access 2007. Speed and...
15
5254
by: OzNet | last post by:
I have a query (with calculated fields) in Access (2007) and the data changes depending on the dates and staff person selected. I need to produce a series of graphs based on the data in this query and it seems to me that Excel is far easier to create graphs than Access. When I use the Get External Data feature of Excel and the dialog box with the tables and queries appears, the query I need is not listed. Is this because the query has...
0
10161
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9955
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9833
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8831
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7378
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
3924
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3531
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2806
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.