mmcgillo88
asked on
Formulas and SQL syntax for Microsoft Access 2007
If I have a data table in Access and I want to get the number of unique ID's in a column (called ID). I then want to get the sum total of everything in a column as long as it is a unique ID.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Yes, I want the count of number of different ID values.
try this query
select ID, Count(ID)
from tableX
group by ID
select ID, Count(ID)
from tableX
group by ID
And if you don't care which value goes into the total you can do...
Select qry1.Count(ID) as NumIds, sum(qry1.Myval) as Total from
(Select ID, first(valuefield) as Myval from tablename group by ID) as qry1
Select qry1.Count(ID) as NumIds, sum(qry1.Myval) as Total from
(Select ID, first(valuefield) as Myval from tablename group by ID) as qry1
ASKER
The above SQL did not work. This is what I have right now:
SELECT DISTINCT inv.InvoiceID, inv.VendorName
SUM InvoiceTotal
FROM tblInvoicesSubmitted AS inv;
SELECT DISTINCT inv.InvoiceID, inv.VendorName
SUM InvoiceTotal
FROM tblInvoicesSubmitted AS inv;
try this
SELECT inv.InvoiceID, inv.VendorName,SUM(inv.Inv oiceTotal)
FROM tblInvoicesSubmitted AS inv
Group by inv.InvoiceID, inv.VendorName
SELECT inv.InvoiceID, inv.VendorName,SUM(inv.Inv
FROM tblInvoicesSubmitted AS inv
Group by inv.InvoiceID, inv.VendorName
ASKER
This looks good. Will this be able to count at the bottom the number of unique invoice IDs as I do not want duplicates?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
My current query is as follows:
SELECT inv.InvoiceNumber, inv.VendorName, inv.DateSubmitted, inv.DateCheckRequested, inv.IM_Check_Confirmed_Dat e, inv.NetItemAmount, DateDiff("d",[DateSubmitte d],[DateCh eckRequest ed]) AS PaymentTime
FROM tblInvoicesSubmitted AS inv
WHERE NetItemAmount<=100 And DateDiff("d",[DateSubmitte d],[DateCh eckRequest ed])<=15
ORDER BY DateDiff("d",[DateSubmitte d],[DateCh eckRequest ed]) DESC;
Please advise where I would put the unique count off function in thsi query. Thank you.
SELECT inv.InvoiceNumber, inv.VendorName, inv.DateSubmitted, inv.DateCheckRequested, inv.IM_Check_Confirmed_Dat
FROM tblInvoicesSubmitted AS inv
WHERE NetItemAmount<=100 And DateDiff("d",[DateSubmitte
ORDER BY DateDiff("d",[DateSubmitte
Please advise where I would put the unique count off function in thsi query. Thank you.
can you create an excel file, fill it with records that you want to see as the result of the query..
i really can't understand what you want to happen.
then upload the excel file
i really can't understand what you want to happen.
then upload the excel file
Are you saying that you want to know the number of Different ID values, no matter how many records for each ID, or do you want the number of IDs which only occur once in the list?
If its the number of Different IDs then does it matter which record goes into the total where there are multiple records for an ID?