473,788 Members | 2,895 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

sql query help! COUNT function

Hi,
I have a following report created from a table

REGION Issue count
South C1 3
South C2 1
West C1 4
North C1 2
North C2 5
East C1 1
East C2 1

Notice that for region west, there is no entry from issue 'c2'. how can
I make sure that report produce a row for every issue and region.
so in this case the report should produce one more row with the
followin entry
West C2 0.

I am creating this report from table which has the following structude

City Region Issue Encounterd?
City1 South C1 Yes
City2 South C2 Yes
City3 West C1 Yes
City4 West C2 No

any help is appreciated

Nov 13 '05 #1
7 1441
can anyone help?

Nov 13 '05 #2
desi90 wrote:
Hi,
I have a following report created from a table

REGION Issue count
South C1 3
South C2 1
West C1 4
North C1 2
North C2 5
East C1 1
East C2 1

Notice that for region west, there is no entry from issue 'c2'. how can
I make sure that report produce a row for every issue and region.
so in this case the report should produce one more row with the
followin entry
West C2 0.

I am creating this report from table which has the following structude

City Region Issue Encounterd?
City1 South C1 Yes
City2 South C2 Yes
City3 West C1 Yes
City4 West C2 No

any help is appreciated


You need a table of Issues and use a left join to the regions.

--
This sig left intentionally blank
Nov 13 '05 #3
I think what you are after can be achieved with an iif statement.
Something like =Iif([FieldName] is null,0,[Fieldname]) This will
ensure a zero and hence a row will be returned.
Nov 13 '05 #4
Yes, someone can help. But you gotta be patient sometimes. I mean,
this thing doesn't get updated instantly... and folks answer when they
have time. Keep yer britches on!

your biggest problem is that if your data tables are not structured
correctly, you CANNOT get data that doesn't exist. You need to design
properly for that. If you had a table of Cities, a table of regions,
then a table of Issues and a table of Encountered Issues, you'd be
fine. You could inner join where you wanted to knock out no matches,
then outer join where you wanted to keep the nulls and you'd be home
free.

Simple answer... join your existing table to a table of ALL the regions
and issues

SELECT Regions.RegionN ame, Issues.IssueNam e
FROM Regions, Issues
ORDER BY Regions.RegionN ame, Issues.IssueNam e)

yes, note the LACK of any join between the tables. It will create a
cartesian product (all possible combinations of RegionName and
IssueName). And then you can LEFT JOIN to that to get the missing
parts. (Use the Find Unmatched Query Wizard...)

If my answer confuses you, try looking up my post from like 6 years ago
that Keri Hardwick answered... maybe that'll help.

Nov 13 '05 #5
please help

Nov 13 '05 #6
please help

Nov 13 '05 #7
ja
On 22 Mar 2005 07:36:38 -0800, pi********@hotm ail.com wrote:
SELECT Regions.RegionN ame, Issues.IssueNam e
FROM Regions, Issues
ORDER BY Regions.RegionN ame, Issues.IssueNam e)


Try adding this to the same query
SELECT Regions.RegionN ame, Issues.IssueNam e
FROM Regions, Issues
GROUP BY Regions.RegionN ame
ORDER BY Regions.RegionN ame, Issues.IssueNam e
Nov 13 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
10238
by: Surendra | last post by:
I have this query that I need to use in an Update statement to populate a field in the table by the value of Sq ---------------------------------------------------------------------------- Inline View Query: Select Sq from ( Select substr(to_date(End_Date,"DD-MON-YYYY"),4), End_Date, Rank() Over (Partition by substr(to_date(End_Date,"DD-MON-YYYY"),4) Order by End_Date) As Sq
9
3137
by: netpurpose | last post by:
I need to extract data from this table to find the lowest prices of each product as of today. The product will be listed/grouped by the name only, discarding the product code - I use SUBSTRING(ProductName, 1, CHARINDEX('(', ProductName)-2). I can get this result, but I had to use several views (totally inefficient). I think this can be done in one efficient/fast query, but I can't think of one. In the case that one query is not...
6
2148
by: John Baker | last post by:
Hi: As those who have looked at this newsgroup recently will realize, I am a neophyte with Access, although I have experienced with Approach (the Lotus product). There are things I could easily do in Approach that appear to require some subtle and complex manipulation in Access. Herein lies my present problem. I have a number of tables, including one called "tblPO", which contains purchase orders. Some of the details of these change...
7
5972
by: Simon Bailey | last post by:
How do you created a query in VB? I have a button on a form that signifies a certain computer in a computer suite. On clicking on this button i would like to create a query searching for all details invovling that computer, for the user to then view. Any ideas on some code? Many thanks for any help.
4
2073
by: d.p. | last post by:
Hi all, I'm using MS Access 2003. Bare with me on this description....here's the situation: Imagine insurance, and working out premiums for different insured properties. The rates for calculating premiums are dependant on the country in which the client is in. Therefore, we have a Country table, with its list of rates, a client table and then the property table. Getting this is great, works fine, easy! Problem is, now I need to work out a...
5
7371
by: elitecodex | last post by:
Hey everyone. I have this query select * from `TableName` where `SomeIDField` 0 I can open a mysql command prompt and execute this command with no issues. However, Im trying to issue the same command inside of mysql_real_query and I keep on getting this error back. "You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use
10
6236
by: aaronrm | last post by:
I have a real simple cross-tab query that I am trying to sum on as the action but I am getting the "data type mismatch criteria expression" error. About three queries up the food chain from this cross-tab query I am using a simple query with no grouping where I am filtering some data out in the criteria line. I have been out of access for a couple years but I remember in the past I had a solution for this but I can't remember. Any help...
11
16333
by: funky | last post by:
hello, I've got a big problem ad i'm not able to resolve it. We have a server running oracle 10g version 10.1.0. We usually use access as front end and connect database tables for data extraction. We have been using oracle client 10.1.0.2 with it's odbc for a while without problem. The problem arose when we decided to reconnect all the tables and save password. Some query became suddenly very slow. Then I've discovered that the tables...
4
2044
by: Doris | last post by:
It does not look like my message is posting....if this is a 2nd or 3rd message, please forgive me as I really don't know how this site works. I want to apologize ahead of time for being a novice with MS Access and VBA. I desperately need help with 2 queries that I am trying to put together. I want to thank anyone that can help me out with this situation. I want to put a select query(Query1) that uses one table and the criteria would...
6
4407
by: jsacrey | last post by:
Hey everybody, got a secnario for ya that I need a bit of help with. Access 97 using linked tables from an SQL Server 2000 machine. I've created a simple query using two tables joined by one field between them. The join field in both tables are indexed and I'm selecting 1 field from each table to lookup. The Access query is taking more than 60 second to retrieve 1 record and if I execute the same query within the Query Analyzer, it...
0
10366
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...
0
10173
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10110
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
9967
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...
1
7517
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
6750
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();...
0
5399
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4070
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
3674
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.