Need Help: Memo Field And Aggregate Functions

Jun 21, 2005

I know SQL well enough, but I cant seem to get my query to work. Basically, I am trying to display a series of posts, with the number of comments on the side.

I have two tables, Entries and Comments, which look like this:
Entries
---------
IDTitleContent (memo field)
1CatsSomething about cats here
2DogsSomething else about dogs here
3RodentsMy pet rat runs in a wheel
etc.


Comments
--------
IDPostIDComments
11My cat's name is mittens
21I taught my cat how to throw a curve ball
33Rats like squeak toys
42Nobody likes dogs
53Bunnies make good pets
61Cats are witches in disguise
Comments.PostID corresponds to Entries.ID on a many-to-one relationship.

I want to run a query that will join the number of comments (which is a Count of each row in the Comments table where Comments.PostID = Entries.ID) to the existing table, so that it will look like this:

Entries (with #ofcomments joined)
----------
IDTitleContent (memo field)#ofcomments
1CatsSomething about cats here3
2DogsSomething else about dogs here1
3RodentsMy pet rat runs in a wheel2
etc.

Usually, this would be a really simple SQL statement, but as I am using a Memo field, I am getting a "cannot use Memo field in aggregate function" error.

I'm not sure what to do, any help would be appreciated :)

View Replies


ADVERTISEMENT

Domain Aggregate Functions To Count Occurrences Of Specific Value In Field

Jul 8, 2012

i need domain aggregate functions to count the occurrences of specific value in a field, and when it exceeds 1, display null. or 'group by' subqueries with count() to see if you should populate the field or not.

View 3 Replies View Related

Aggregate Functions In Where Clause

Aug 29, 2005

I was wondering if anyone can help me: I have for example Pupils that are being entered into a table (called log). A query then counts the number of entries for each pupil I then want it ONLY to show the pupils that have been entered in 10 times on todays date (using DATE()).
I know this doesnt work but this is what I want to do:

SELECT log.pupilNo, log.Forename, log.Surname, Count(log.pupilNo) AS Demerits
FROM log, Tally
WHERE (log.Date)=Date() AND COUNT(log.pupilNo)>9
GROUP BY log.pupilNo, log.Forename, log.Surname, log.pupilNo;

Apparenty you cannot have an Aggregate function in a where clause.
Does anyone know a solution, any help would be appreciated
Cheers
Bikeboardsurf

View 2 Replies View Related

Add Calculations To Existing Aggregate Functions

Oct 16, 2006

Hi,

Is it possible to add a calcualted field to a query that already uses 'sum'?
I want to take the value returned by sum and add the value of another field to it.

Any help will be very much appreciated.
B

View 12 Replies View Related

DLookup/Aggregate Domain Functions

Jun 7, 2007

Is there any way to lookup items using DLookup or other functions that will return an array of values not just the first value found. Example: I have three employees in a complaint query. I am using Dlookup to identify them on my employee form. When I get to the same employee/employee id on my employees form, I have a label that flashes red to flag me that this employee appears on that complaint query. The problem that I am having is that it only flashes for the first employee found in the query, and the label only flashes for that one person. I would like the label to flash for the other two employees because the function should see that they are in the query results as well. Help please?!!!

View 2 Replies View Related

Queries :: Aggregate Functions With Conditions?

Mar 22, 2013

I have the following query. I got an error when I ran it.

Code:
SELECT COUNT([encounter_number] WHERE status = 'Death')/ COUNT([encounter_number]) AS Death Ratio, tbl_test.facility_type AS Type,
FROM tbl_test
GROUP BY tbl_test.facility_type;

I think the problem is that first WHERE clause inside.

View 2 Replies View Related

Domain Aggregate Functions In Query Expressions

Apr 3, 2007

Alright, I've got all the pieces to this puzzle, I just can't fit them together properly. I have two tables, tblTickets and tblTicketNotes. They are in a one-to-many relationship, there can be multiple Notes attached to a single ticket. I am trying to set up a query that will pull the first (earliest by date) note for each individual Ticket. Here are the fields from each table that would be of concern here:

tbTickets
TicketID - Autonumber - Primary Key
Issue - Text - I will be using this later as a criteria to limit with, but not neccessary

tblTicketNotes
NoteID - Autonumber - Primary Key
TicketID - Long Integer - This is the foreign key of the relationship
DateStamp - Date/Time - This is the Note Date, I only want the first (earliest date) one
Content - Memo -This is the note information I want

So all I want is the Content of the first/earliest Note for each individual Ticket. I know this should be fairly easy, but I am at a loss.

View 2 Replies View Related

Forms :: Syntax For Nested Aggregate Functions?

Feb 4, 2014

I have a problem with a nested arrangement of Right, DLookup and DMax functions.

The function is for a default value in a text control

=Right(DLookUp("[SampleNumber]","tbldat14A_MasterSampleList","[SampleID]=" & DMax("[SampleID]","tbldat14A_MasterSampleList"))+1000001,6)

I am trying to retrieve the last record from a field SampleNumber which is alphanumeric (e.g. "AK005434") and then add a 1 to it as the next SampleNumber. I had previously used a default value in the txtSampleNumber control as

="AK" & Right(1000000+DMax("[Clip]","[tbldat14A_MasterSampleList]")+1,6)

where [Clip] was a field I have calculated in the table to chop off the preceding characters. Adding 1,000,000 and taking the 6 right hand values and concatenating with "AK" gave me the answer, though it is a but primitive.

This all worked until the SampleNumber value got out of order and blocks of SampleNumber values came in that were then followed by blocks of numbers with lower values (say AK005001-AK005050 followed by AK002001-AK002050).

Now I figure if I just recall the latest entry by DLookup and criteria of DMax on the SampleID (Autonumber Primary key) I could get at the value. I have done this to some success using default values in a series of unbound controls like

=DLookUp("[SampleNumber]","tbldat14A_MasterSampleList","[SampleID]=" & DMax("[SampleID]","tbldat14A_MasterSampleList"))

to get the SampleNumber I require, then a Right function to trim in another unbound box and then use that last unbound box as the default value for the txtSampleNumber control that is the entry for the data table. However, the unbound control box is only valid for the first record and does not update. So, I added a macro that closes the form and reopens it. This all works but is a bit agricultural. I would like to do a single nested function to the default value of the txtSampleNumber control box. Is it possible to nest Right, DLoopkup and DMax into one statement?

View 14 Replies View Related

Troubles With Aggregate Functions In Queries And Null Values

Jun 26, 2007

I'm having a problem with queries, and I can't seem to find a solution in books - I looked through about ten of them and none of them addressed the problem. This may be because it has a painfully obvious solution...

A little background:
I am designing a database for a debt-collection law firm. One of the functions it must have is to keep track of various different sorts of financial transactions which can pertain to a given debtor (ie, a received payment, a cost expended, and a few other things).

The problem is that, in generating reports, I need to use queries to find several sums of only those transactions which fall into specific categories (for instance, to calculate the amount a debtor has paid against his balance, it needs to sum only those entries which are both linked to that debtor's ID number and whose type field reads "payment", and then subtract from that those entries whose type field reads "cost"). The problem is this: not all debtors may have "costs" entries, and when there are none, the report comes up blank with a single "#Error" written in the name field and nothing else present.

I believe the problem is that the Sum aggregate is returning a null value when the query finds nothing that meets the criteria. I have been unable to find a way around this; the Nz() and IIf() with IsNull() functions don't seem to be helping.

The query runs as intended when there are entries for every relevant type; however, it is undesired to have to enter a "payment" of $0, "cost" of $0 etc for every entry just so that this function works.

Is there anything I can do about this? Any input would be appreciated, as I'm fairly inexperienced with the use of Office Access. (If it matters, I am using Office 2003).

View 2 Replies View Related

Forms :: Insert A Field That Sums Up / Aggregate All Values Of Field

Jul 25, 2014

i want to add a control in that form that sums up and aggregate all the values of field called [amount] based on the value of [Name_Patient] as criteria

View 2 Replies View Related

Field Does Not Exist - Any Useful Functions?

Aug 6, 2007

I need a function or way of dealing with a field that may or may not exist.

I am crosstabbing a large database and then building queries on the crosstab. However, the field from which the column headings come does not always have the same data in it as I have to cut the data in different ways (always similar but not always the same). As a result, sometimes I get the error message:

"The Microsoft Jet Engine doesnot recognise [FIELD] as a valid field name or expression"

where a field I was expecting did not appear.

If it was a null value within a field I remove it like this:
iif([Field] is null, 0, [Field])

Is there an equivalent formula for "exists" that will stop my queries falling over when it cannot find the field?
eg iif(exists([Field]),[Field],0)

Any help, guidance or assistance gratefully received!

View 2 Replies View Related

Modules & VBA :: Field Names In Functions

Oct 23, 2014

Adding fields into a function has been a problem for me:

Code:
IIf((Count([qryADDR].[Fuel Type]>2), 'MPS', [qryADDR].[Fuel Type])

The logic I'm trying to create is the following: If the number of Fuel Types is greater than two, then the field will have the value 'MPS.' Otherwise, the field will just have the regular fuel type value. It's referencing this fuel type field in the function that is the problem. I have not been able to get this working.

View 5 Replies View Related

Queries :: IIF Functions - Control Source Of A Field In Form Data

May 8, 2014

I am new to access, after learning basics I am trying to build my first DB.

Having some troubles with the IIF syntax. I am placing the formula

=IIf([Total]<=(200),[Total]*(0.7)) & IIf([Total]>(201)&[Total]<=(500),[Total]-(200)*(1)+(140)) & IIf([Total]>(501),[Total]-(500)*(1.2)+(300)+(140))

In the form data control source of a field. The first 2 statement seems to work, but the last statement results in some crazzy figures.

View 3 Replies View Related

Forms :: Cut / Copy / Paste - Activating Mouse Functions In A Field?

Aug 8, 2013

How do I activate functions mouse functions in a field? I want to click the right key of the mouse when I'm in a field within a form so I can cut, copy, and paste.

View 2 Replies View Related

Converting A Text Field To A Memo Field

Jan 4, 2006

I am in the process of changing over a text field to a memo field to generate more space (in 5 different databases :eek: ) Thanks to all the good info on several searches of this forum, I am pretty clear on how to do that.

The question is... when I convert a field that already has information in it, will I lose the current information?

TIA,

Darnys

View 2 Replies View Related

Memo Field - How To Stop Highlighting In Field

Aug 7, 2006

when i change records, my subform that has a memo field, shows the memo field data is "highlighted". i can make a mistake and hit any keyboard key and the memo field data will get erased.

is there a way to prevent such a problem?

if not, is there a work around. eg, hide the memo field until needed for more input? ideas on both issues?

View 1 Replies View Related

Truncating Memo Field

Jan 26, 2006

I am using

DoCmd.OutputTo to export a query but this truncates the memo fields, but in the db window,right clicking and choosing to export does not truncate the data.


How do I code to output all the data without truncating?

View 1 Replies View Related

Memo Field Not Showing More Than 255

Jun 23, 2006

Hi guys and Girls

I have a txt box on a report which should show comments..
In the background table the field this txt box is bound to has a data type of memo. Yet the txt box on the report stops showing any more than 255 characters! any clues? I know 255 is the field size set for my Txt fields but memo fields should be able to display 65000000000000000 trillion characters with no problems.

When I look at the table the memo field has all the txt in it, it just wont display all the txt on the report.

Thanks for any help guys.

View 1 Replies View Related

Text Vs. Memo Field

Jul 28, 2005

Are there any other advantages in using a text field verses a memo field other than memory allocation? Memory allocation seems like such a small issue these days.

View 3 Replies View Related

Imported Memo Field

Mar 1, 2007

Hi, i have a fox pro memo field that has bill of materials information in like so:EACH KIT COMPRISES

1 CR10070SW £29.60 HALLITE PRODUCT
1 RBS24690 £0.82
1 RBS354 £0.95
2 RBS345 £0.75
1 S95MMEXT £3.90


£36.77 PER KIT

I need to take out the carriage returns but keep the items delimited in some way so they all apear on the one line. These are the child parts for kits so i need to keep them on one line as i import them or via a query so i can see the parent part they belong to.

Many Thanks

View 3 Replies View Related

Memo Field Length

Mar 26, 2007

Hello,

If I read the documentation then memo field in a Access table can be 65.000 chars long.
I have three memo fields in a linked ODBC table which is filled by a append query from SQL-server database. The text in these field is cut off by 255 chars.
Does somebody know what the cause of this can be?

1. Is there a limitation/property where I can configure the length of Access memo field? DAO? I have read something about this but I don't understand this.

2. How can I trace that everything is send from the source? Maybe it's cut off at the source site. On this moment I don't know something about a Linked tabel.
Is there a sniffer or trace tool so that I can see what kind of data is realy send?

Thanks in advance

Nico

View 2 Replies View Related

Query A Memo Field

May 31, 2005

Greetings All -

Let me say first I am a novice Access user, just trying to teach myself a few things to make my job easier. So take it easy on me with any feedback.

This is my situation. I am using a web based help desk ticketing software that has an Access DB. I have created a couple of queries and linked them together that seem to be working and giving me the data that I want with one exception.

I am tring to query a memo field, which is the description of a ticket, and the output is only a small portion of what is actually entered in to the table. Is there a way either in my query or report builder to make a change that will output all of the data from the description field?

A couple of things that I've tried on my own are to change the data type for that field from memo to text, however that that puts limits on the amount of data that can be entered in and causes the help desk software to function incorrectly. I've also turned on Can Grow and Can Shrink for the text box for the output in my form.

Any help you can offer would be greatly appreciated.

Thanks.
Jason

View 1 Replies View Related

Memo Field Truncating :s

Nov 23, 2005

Hi,

Ok, firstly i have search google and this forum from top to toe and no-1 has an answer that works for me.

I am running a query, now i have completely simplified it. The query is now just picking up a field called recommendations. Recommendations is a memo field with no formating or index on at all. Now, when i run the query as normal it works fine... everything is there. But when i have to group by it. It cuts it off at 255 charactors. The thing is i need to do some sums and counts within the query aswell so it has to be.

I have checked microsoft and there suggestions are not any use.

Any ideas???

View 2 Replies View Related

How To Query A Memo Field?

Dec 8, 2007

Hello,

I have Custormers table.

Name : Text
Address : Text
BDate : Date
Notes : Memo

Sometimes, I need to query Memo field.

I have a CForm which has a field named Search.
I want to query all Notes fields in Customers table via CForm!Search field.

Should I make a query like this? I use IN but I doesn't work.

SELECT Customers.Notes, Customers.Name, Customers.BDate
FROM Customers
WHERE (((([Forms!CForm!Search]) In (Customers.Notes)));

Thank you for your help,

Osman

View 1 Replies View Related

Memo Field Limitations

Mar 26, 2005

I have a form with a memo field. This field is based on a table with a field set as a memo data type. The problem is that although the form field lets you type endlessly, it only saves 255 characters. A memo field is supposed to let you enter up to 64000 characters. Has anyone else ever had this problem, if so what was the solution?

View 1 Replies View Related

Memo Field Punctuation

Jun 8, 2005

I have a form set up where user's type in an explanation of how a claim is being appealed and resolved in a memo field.

One problem, for some reason management doesn't want these explanations to end with a period. But the users keep ignoring our request and keep using the period.

Is there a way that you can code this memo field to where it will allow punctuation throughout, except at the end?

View 1 Replies View Related







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