473,385 Members | 1,311 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Count Distinct in access while totaling up values

I have two columns of data something like this:

A 11
A 12
B 14
C 15
C 42
C 94
D 12

I want my query to result in a distinct count of data in column 1 and sum of column 2. So result should be something like:
4 200

I think one way could be to first run a query to group by column 1 and sum of column 2 and then on resultant table run a count of column 1.

However I want to explore if there is a way within ms-acces of skipping above make a single query.

Tx,
Sagar
Attached Files
File Type: txt sample.txt (42 Bytes, 409 views)
Nov 16 '11 #1
1 1381
TheSmileyCoder
2,322 Expert Mod 2GB
This is SQL using subqueris and it works for me.
Expand|Select|Wrap|Line Numbers
  1. SELECT Count(A) AS CountOfTxt, Sum(B) AS SumOfNo
  2. FROM (SELECT t.Txt as A,Sum(t.No) as B
  3. FROM tbl_Demo as t
  4. GROUP BY t.Txt);
  5.  
Where txt is the text column and No is the number column.

If you have any questions please ask.
Nov 16 '11 #2

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

Similar topics

0
by: puskas | last post by:
I'm trying to make a report of users per hour (I have one that works for users per day) but when I execute the query I realize that I get more users than the ones I have here is my query ...
2
by: Michael Howes | last post by:
I have a single DataTable in a DataSet. It has 4 columns and i'd like to get a handful of counts of unique items in 3 of the 4 columns. Can a DataTables Select or Compute methods to COUNT DISTINCT?...
2
by: P K | last post by:
I am using server.transfer for a website being developed in vs.net 2005 And I need to get the posted values after server.transfer. For this I set the second parameter "true" in the transfer...
2
by: Chuck C | last post by:
Is there a way to access the values from a session by using an index/count instead of the name? Something like: $_SESSION Also, can you query the name and value for this? What I am...
1
by: jerry.ranch | last post by:
I see that Access 2003 doesn't support count distinct?? I have a work around, but one statement would be preferably of course Jerry
1
by: aps786 | last post by:
Hi, There is a table where I store ipaddress and user who logged in from that IP. I have a query to findout all ipaddresses, from where diff users had made request. stat ------------ ip...
4
by: Mina Patel | last post by:
Hi trying to find the number of duplicate tuples/records in table based on multiple columns ie. select count(distinct list multiple column key ) from x where date = y HAVING ( COUNT(multiple...
5
bhcob1
by: bhcob1 | last post by:
Hi guys, I have access 2000, I have a form frmCSOC, with a field that can have duplicates, I want a label to display how many records there are with DISTINCT values. I have heard that the...
4
by: tom booster | last post by:
Hi All, I'm trying to convert a T-SQl query to DB2. I have two tables policy and policyHolder. I would like a count of the amount of distinct poicyHolders per policy, for a particular set of...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.