Queries :: Selecting Max From Grouped Data

Nov 26, 2014

I am having trouble writing what I think should be a fairly straight forward query... I am have a table with 2 fields, the first contains a list of subjects, the second contains a list of scores that students got in their tests in that subject.

So the data looks like this:

Maths 54
Maths 69
Maths 41
English 71
English 55
Art 44
Art 43
Art 66

I would like to write a query that selects only the highest score for each subject and presents it like this:

Maths 69
English 71
Art 66

View Replies


ADVERTISEMENT

Queries :: Calculate Percentage On Grouped And Filtered Data

Jul 20, 2015

I'm very new to Access and I'm attempting to write an expression in a query that will calculate the % of the count of "Exchange" field (Exchange is a text field and is grouped and the count based on each unique name) where the total count is based on the filter where "Group" = 'FS' or 'S'.

The below seems to work, but there is a better way of going about this (especially if I have to add more filter criteria). I added a pic of the query I'm trying to build.

PercentofTotal: (Count([Exchange])/DCount(Count([Exchange]),"[Holdings]","[Asset Group] = 'FS' OR [Asset Group]='S'"))

View 11 Replies View Related

Merging Grouped Data?

Apr 3, 2008

So i'm not sure where this post belongs as it may encompass several items.
I have an excel sheet where every row has an email address and a product purchased. I've imported it all into access but would like to run a query to find out how many people that bought x purchased y. Or tell me how many people that x did not buy a,b, or c.

Part of the problem is that each record is one product. My data looks like this:

email: Product:
e1 p2
e1 p7
e1 p33
e2 p2
e2 p9
e3 p1
e4 p1
e4 p3

I was able to group some of the data by email address in access but can't figure out a good way to query it. I'm thinking I probably need to merge the data where each unique email address is a record and the products have all the products purchased instead of just one but I really have no clue how to do that.

Is this easily do-able? how would I go about this?
Thanks alot!

View 2 Replies View Related

Queries :: Add Comparatives To Grouped Totals Queries

May 23, 2013

I have a totals query of phone call charges by phone number and I want to show a "budget" amount for each number (same amount for all) and a variance against that budget.

How I can do this at the grouped (phone number) level rather than at the individual call level?

Please see current query below:

SELECT Call1CurrentTbl.電話番号(MSN), Sum(Call1CurrentTbl.料金) AS 料金OfSum
FROM Call1CurrentTbl
GROUP BY Call1CurrentTbl.電話番号(MSN), Call1CurrentTbl.[レコード区分], Call1CurrentTbl.表示区分
HAVING (((Call1CurrentTbl.[レコード区分])=2) AND ((Call1CurrentTbl.表示区分)=10));

View 2 Replies View Related

Queries :: Add Columns To Grouped Max (date) Query

Mar 14, 2013

I have a database that tracks students and their test scores. I am trying to figure out a way to where it will pull the student's latest test score and compare it to see if they fall within standards. So far I have 3 tables.

tblStudents
studentID
studentName
studentEmail

tblResults
resultID
resultStudent
resultDate
resultTest
resultScore

tblTests
testID
testName
testPassScore

The query I have written looks like this: SELECT tblStudents.studentID, Max(tblResults.resultDate) FROM tblStudents LEFT JOIN tblResults ON tblStudents.studentID = tblResults.resultStudent GROUP BY tblStudents.studentID." The data pulls just fine at this point. What I'm trying to figure out is how to then add more columns to this query to start doing comparisons. When I try to add more columns it tries to use them for additional grouping and adds many more records.

View 8 Replies View Related

Queries :: Totals Query Grouped Across Columns

Mar 5, 2015

I have simple table data structured as follows;[Origin], [Code], [Weight]. The Code field is a lookup field that will contain one of 8 choices; 10, 13, 13c, 23, 25, 27, 27a, & other. The other fields are pretty much self explanatory. Sample data would look like this:

Code:
Origin Code Weight
Edison 13 4.25
Edison 13c 2.87
Piscataway 10 5.45
Middlesex 23 1.24
Edison 13 5.21

What I need to create is a totals query where I first group by origin value, then a column for each "code" value which totals the weight for that "code". A sample output would look something like this:

Code:
Origin 10 13 13c 23 25 27 27a other
Edison 9.46 2.87
Piscataway 5.45
Middlesex 1.24

The only way I can think to accomplish this is to restructure the original table to include a field for each code and enter the weight in the appropriate 'code' field. If this is the only solution then Ill have to live with it, but is there any way to create this output using my original structure?

View 1 Replies View Related

Queries :: Count Active Members Grouped By Month

May 5, 2015

I am trying to get active member count by month in MS Access.

Table looks like this:

admin ID firstName sDate eDate 1 Adam 01/01/2015 01/04/2015 2 Ben 01/02/2015 15/04/2015 3 Carl 01/02/2015 13/03/2015 4 Don 13/01/2015

Required output would be like this

2015-Jan: 2
2015-Feb: 4
2015-Mar: 3
2015-Apr: 3
2015-May:1
etc..

I got this far:
SELECT DISTINCT count(a.ID) as mCount, year(dimDate.Date) as [Year], month(dimDate.Date) as [Month]
FROM admin AS a INNER JOIN dimDate ON (dimDate.Date >= a.sDate AND dimDate.Date <= a.eDate) OR (dimDate.Date >= a.sDate AND dimDate.Date = null)
GROUP BY year(dimDate.Date), month(dimDate.Date)
ORDER BY year(dimDate.Date), month(dimDate.Date)

Query4 mCount Year Month 31 2015 1 71 2015 2 44 2015 3 13 2015 4

View 2 Replies View Related

Queries :: Grouped Query That Returns A List Of All Periods

Nov 21, 2013

I have a grouped query that returns a list of all periods qryPeriod

Code:
SELECT [tblMaster].Year, [tblMaster].Week, ([Year] & " - " & Right(0 & [Week],2)) AS Period
FROM [tblMaster]
GROUP BY [tblMaster].Year, [tblMaster].Week, ([Year] & " - " & Right(0 & [Week],2));

Year | Week | Period
2013 | 48 | 2013 - 48
2013 | 49 | 2013 - 49
2013 | 50 | 2013 - 50
2013 | 51 | 2013 - 51
2013 | 52 | 2013 - 52
2014 | 1 | 2014 - 01
2014 | 2 | 2014 - 02
2014 | 3 | 2014 - 03
2014 | 4 | 2014 - 04

[code]...

these are then used as the start of a between lookup against [tblMaster] along with the last record in the qryPeriod (2014 - 04)...I will need 4 queries so If someone can sort out last period - 8 I can probably do the others.would DLookUp do this say return the last 4 values, Last 6 Values and Last 8 Values

View 6 Replies View Related

Queries :: Concatenate Multiple Records Grouped By Date?

May 2, 2014

I have a rates table with 3 fields : [RateDate], [CurrencyID], [FXRate]

I also have a currencies table with 2 fields : [CurrencyID], [CurrencyCode]

Where [CurrencyCode] is just the 3-character currency code (i.e. EUR, GBP, USD etc.)

The rates table uses a composite primary key across [RateDate] and [CurrencyID] - i.e., there should only be one unique record for each combination of date and currency.

Not every date will be present in the table and, within each of those dates, not every currency will be present (but at least one, obviously)

I want to write a query which will return two fields. The first field will contain all of the unique dates in the table for which the [FXRate] field (for any currency) is blank / null. Straightforward enough :

Code:
SELECT [tblRates].[RateDate]
FROM [tblRates]
INNER JOIN [tblCurrencies]

[Code]....

But this gives me a separate record for each date / currency combination in the returned dataset. I just want one record per date and all of the currency codes in a single string (separated by some delimiter) as a text field.

View 3 Replies View Related

Queries :: Grouped Sum With Proportion Of Total (Access 2007)

Feb 20, 2015

I have a table of transactions (close to 1m records) from which I want to query totals by currency and direction (ins and outs) and then also show the proportion of the overall total for each currency. All amounts are absolute (i.e. ins and outs both represented by positive numbers)

To throw some added complexity into the mix, the transaction table records only refer to account (AccountID), which links to a separate account and currency tables.

I can query the sum totals by currency and direction (although I'm not totally happy with the SQL syntax .

Code:
SELECT tblCurrencies.CurrencyCode,
tmp1.SumPay,
tmp1.SumPayUSD,
tmp2.SumRec,
tmp2.SumRecUSD

[Code] .....

I'm struggling to get the proportions per currency though? I tried adding :

Code:
((SumPayUSD+SumRecUSD)/Sum(tblTransactions.USDAmount)) AS Proportion

But it tells me that the specified field 'tblTransactions.USDAmount' could refer to more than one table listed in the FROM clause of the SQL statement.

View 3 Replies View Related

Modules & VBA :: Get Filtered / Grouped External Data Into MS Access Table

Oct 20, 2014

I have an Excel file with a name range "DBIAS" which identifies all database data.

Then I have an Access file with a form to import that database (better, that named range) into an Access table. While importing, I have to filter some records or grouping by some field.

I cannot run correctly a VBA code to get data (filtered and/or grouped) from that name range and save those records to an existing or a brand new table.

I could get those data as DAO.recordset and printed out with "Debug.print" on immediate window, but I cannot complete the final step: writing those records to a table.

View 3 Replies View Related

Queries :: Query Between Dates But With Count Grouped By Model Number?

Mar 18, 2013

I currently have a query of between dates which the user enters, but when I try to get a total count of model numbers it gives totals for each date. I am trying to get a count of model numbers between these dates with the dates excluded in the grouping.

View 14 Replies View Related

Cleaning Up "Grouped" Data

Oct 26, 2005

I have a question and I'll apologize in advance because it may or may not really be an Access question.

I have a large ASCII spreadsheet that I have imported into Access. It has 4 columns, and has these headings: CodeID, Group, Division, Account. Many Division and Account combinations can exist within a Group, and there can be many Groups under a specific CodeID. Unfortunately the way I received the data was in a grouped fashion, like so:

CodeID Group Division Account
1234 1111 0001 0001
0002 0002
2222 0001 0001
0003 0003
1235 1111 0001 0001
0003 0003
etc.

Is there a way - easy or otherwise - to populate the blanks with the appropriate information? Essentially to "ungroup" I guess. I need to do this so I can sort and modify the data. Obviously as it is I can't do much with it.

Note, when I imported the data I had Access add unique counter as a primary key. That is allowing me to keep the data in order, but doesn't help beyond that.

Any suggestions???

View 7 Replies View Related

Selecting Data From A Combobox To Get More Data In A Listbox

Nov 21, 2005

im new to this so hello every1!!!

umm.. i have a form with a combo box which is linked to a table which gives me customer id numbers. and i have a listbox which i want the names and addresses to appear when i select a cusotmer id number from the combo box

so on the list box i put
" SELECT CustName FROM Customers WHERE CustID=$combo43; " in row source; if i change $combo43 to 0 the name appear but that is fixed and i want it 2 change when i select a cusomer id number from the combo box

can some1 plzz help me, its 4 my college project!

thanxs in advance!

purejoker!

View 1 Replies View Related

Selecting Data

Feb 18, 2005

hello,

im trying to select data from an access database via asp. the data must be stored in a recordset and fit the criteria as given in the variable varItemSelected:

heres what i have

SQLstmt = "SELECT * FROM Products WHERE product = " &_ varItemSelected

set rs = con.Execute(SQLstmt)

but i get the error:
Microsoft JET Database Engine error '80040e10'
No value given for one or more required parameters

any ideas?

thanks

View 3 Replies View Related

Queries :: Selecting Only The Max Row Through SQL

Aug 11, 2015

A query TaxType_Query produces the following results

TaxType; FromDate; ContactID, FullName
W2; 7/1/15; 1, Tom
1099; 4/1/15; 1,Tom
W2; 1/1/15; 1, Tom
W2; 1/1/10; 2, Dick
1099; 1/1/09; 3, Harry

I need the query to show only the rows with the maximum FromDate for each ContactID (result would be the 1st, 4th and 5th rows only). I assume there is a quick SQL statement that will work better than Totals / Max criteria method. If I set the FromDate criteria to Max the TaxType field is a problem as they have different values I cannot group by that field.

View 1 Replies View Related

Selecting Data Between Two Dates

Mar 5, 2008

I have a database which records time spent on various projects and I would like to be able to calculate the time spent on any particular project between two selected dates. The report and the query behind it already works to display the time accrued on all the dates of a project, but I want to be able to break it down to small ranges of dates

I have a form on which the user selects the start date and the end date. How can I apply this calculated information as a criteria in a query so that I can produce a report with the relevant information on it.

I already have the report and the date selection form designed. The dates selected go into two unbound fields which have a date format.

I hope someone can help me.

Rob

View 6 Replies View Related

Selecting Data From Subform

Jan 17, 2006

Each record in the database has a subform (one to many relationship) with multiple records. When the user clicks on a record in the subform I want the information from the subform and from the mainform to go into a Word document. I am able to pull the data from the main form but not from the sub form. Any suggestions would be appreciated. Below is an example of what I am using to get the data out of the main form for the bookmark in Word called "ClientName".

.ActiveDocument.Bookmarks("ClientName").Select
.Selection.Text = (CStr(Forms!frmClients!txtFName) & " " & (Forms!frmClients!txtLName))

View 3 Replies View Related

Code Help In Selecting Queries.

Dec 14, 2004

I am needing help with how to set up the code to select different queries based on different conditions.

The database is to be set up so that I can pull studies at different time points based on if they are under long term, accelerated or stressed conditions. When this condition is selected there are only certain time points which are to be run,
example.....
Long term: 3,6,9,12,24,36,48 and 60 months.
Accelerated: 3,6,9 and 12 months.

As you can see I have the dates calculated for all of the weeks and months that the sample could be pulled at, Inventory Transactions Table. And I am able to generate throught the Pull Dates Form a list of only the records to be pulled under Long Term conditions. I would like to have the form set up so that when I choose the Accelerated condition that it would pull from another Query like the Pull Dates Long Term, but only have the Accelerated time points listed.

I am not sure if I need an If/Then statement and if so how do I set this up.

View 6 Replies View Related

Selecting Data And Incrementing Using DMax

Jun 27, 2007

I have data in a table
I am extracting using an append Query, I wish to assign a number from the original table +1 to the records pulled by the append query.
I am very new to this and have the expression below, however the result is #error in created field CertifNumber
The data I am looking for is in table Sample Details and the Field is CertNo

CertifNumber: DMax([Sample Details]![CertNo],"Sample Details","[Sample Details]![CertNo]+1")

If somebody could help me with this expression I would be very grateful.

Thanks

Richard

View 3 Replies View Related

Selecting Data From Multiple Table

Nov 17, 2004

Hi,
I have 13 tables in all. 2 are Area and Scope which have unique entries of areas and scope and the remaining 11 will have a primary key, Tag_No.
I want to select data from these 11 tables such that ALL the data will be pulled out but say table 1 has a column MOC and remaining 10 tables dont, then it will be a blank or null in those columns for the 10 tables. How can this be done? (I hope I am not confusing!!!)
Adwait

View 3 Replies View Related

Selecting Data For Monthly Report

May 5, 2014

I am constructing a database for a friend and need to filter data from a daily log to enable a report to be generated for each months actions. I have created fields of: entry date, month and year with the view of filtering by month and year. How do I perform this task?

View 3 Replies View Related

Queries :: Selecting Dates From A List

Dec 11, 2013

I have a table containing a list of dates in "MMM YYYY" text format from "Jan 2010" to "Dec 2020".

I would like to restrict the list from the first record (Jan 2010) to the current month using today's date (eg in this case Dec 2013).

I know about

Code:
Format(Date(),"mmm yyyy")

And have tried the criteria

Code:
<Format(Date(),"mmm yyyy")

But doesn't work and haven't got much further....

View 6 Replies View Related

Queries :: Selecting Maximum Value For Each Primary Key

Mar 9, 2014

I am doing an outline design of a database system to handle the results from an archery competition in a couple of weeks.

Currently I have a table with a primary key to hold the information on the competitors (name, age etc.) and this is linked to a table via a foreign key (the archers name) to enable multiple scores to be recorded against each archer.
For the purposes of the competition only the first score shot each day is valid and so I am using a yes/no box to filter out these results.

What I would like to do is then filter the results such that only the largest of these first session scores is displayed for each archer. (i.e if archer A shoot 578 on day 1 and 585 on day 2 i would like the database to only report the 585, and similarly for the other entries).

View 2 Replies View Related

Queries :: Selecting Latest Row For Each Year

Dec 18, 2014

I'm having trouble with a simple query. They have an access database with a table like this (simplified for this example):

--------------------------------
Name Result Date
--------------------------------
Bob 5 1/1/2014
Bob 6 2/2/2014*
Bob 7 3/3/2015
Bob 8 5/4/2015*
Len 5 1/1/2014
Len 6 2/2/2014*
Len 7 3/3/2015
Len 5 7/4/2015*
---------------------------------

how I would write a query that gives me the latest result that each person earned in each year (I put a * symbol against the rows above that I am talking about)?

Bob 6 2/2/2014
Bob 8 5/4/2015
Len 6 2/2/2014
Len 5 7/4/2015

(The database is normalised and this table has an ID field).

View 5 Replies View Related

Queries :: Selecting Fields In Query

Jan 24, 2014

I have a query that is used to capture all the fields that can be possibly used.When run & exported to excel the user then simply deletes the columns with the fields that they don't require.We do this so we don't have to keep creating queries over and over again when you just use one that does all but then delete what you don't need afterwards.

Any way of using a form with tick boxes for each of these fields so when they user ticks the fields they require reporting on then only those fields will be returned in the query.

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved