SQL FORMULA FOR ACCESS

johnkylex

New Member
Joined
Mar 22, 2004
Messages
1
I track data on problems with certain hardware. These problems are categorized by repair codes. I track the type of hardware someone has, the date, and the repair codes. What I would like to do is to take the last full week of data. Take the top ten repair codes used to track problems, and then plot the history of those ten repair codes and their date.

This way I will get to see my top ten problems for the previous week and see the past history trend for those repair codes.

Thanks,
John
johnkylex@yahoo.com
 

Excel Facts

Create a Pivot Table on a Map
If your data has zip codes, postal codes, or city names, select the data and use Insert, 3D Map. (Found to right of chart icons).
Three SQL Queries. Last Gives you a List of all valid entries for those specific top 10 trouble codes. First Query is a Crosstab, the second gives you the TOP X entries, and the third Joins the original table to add additional information. Please pardon the field names as I pulled this quickly out of a test database for a completely unrelated type of function.

Summarize the information by counting the entries within the time frame
Code:
TRANSFORM Count(tbl1.fld1) AS CountOffld1
SELECT tbl1.fld2, Count(tbl1.fld1) AS [Total Of fld1]
FROM tbl1
WHERE (((tblD1.Datefld4)>=Now()-7))
GROUP BY tbl1.fld2
PIVOT tbl1.fld3;

Give me the top 10 entries
Code:
SELECT TOP 10 qry1.[Total Of fld1], qry1.fld2
FROM qry1
ORDER BY qry1.[Total Of fld1] DESC;

Join the top 10 list to the original table on the field counted and list all results.
Code:
SELECT tbl1.Number, tbl1.Datefld4
FROM tbl1 RIGHT JOIN qry2 ON tbl1.fld2 = qry2.fld2;

Mike
 
Upvote 0

Forum statistics

Threads
1,221,657
Messages
6,161,084
Members
451,684
Latest member
smllchng5

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top