Select Query


R

Rebeca

I've created a random record query that works. It pulls 50% of
records
for a particular timeframe. The problem is that I don't want random
records, I actually just want it to pull 50% of records for the
timeframe based on another criteria ([prac name]). The reason I want
to pull the same records each time is it will take more than one day
to perform the audits.

Any suggestions???

Here is my SQL.
SELECT TOP 50 PERCENT EncountersToAudit.ID, EncountersToAudit.[Prac
Name], EncountersToAudit.[Created By], Staff.[last name]+", "+[first
name] AS FullName, EncountersToAudit.[Enc Dt],
EncountersToAudit.Encounter, Rnd([encounter]) AS RandomValue,
EncountersToAudit.[Pat Name], EncountersToAudit.[Chkin Dt],
EncountersToAudit.[Crt Dt], JobDescription.[Job Title]
FROM JobDescription LEFT JOIN ([Staff Query] LEFT JOIN
EncountersToAudit ON [Staff Query].FullName = EncountersToAudit.
[Created By]) ON JobDescription.JID = [Staff Query].[Job Title]
GROUP BY EncountersToAudit.ID, EncountersToAudit.[Prac Name],
EncountersToAudit.[Created By], Staff.[last name]+", "+[first name],
EncountersToAudit.[Enc Dt], EncountersToAudit.Encounter,
Rnd([encounter]), EncountersToAudit.[Pat Name], EncountersToAudit.
[Chkin Dt], EncountersToAudit.[Crt Dt], JobDescription.[Job Title],
Year([Enc Dt])*53+DatePart("ww",[Enc Dt])
HAVING (((JobDescription.[Job Title])="front office" Or
(JobDescription.[Job Title])="float staff") AND ((Year([Enc
Dt])*53+DatePart("ww",[Enc
Dt]))=Year(Date())*53+DatePart("ww",Date())-1))
ORDER BY Rnd([encounter]);
 
Ad

Advertisements

J

John W. Vinson

The problem is that I don't want random
records, I actually just want it to pull 50% of records for the
timeframe based on another criteria ([prac name]).

You'll need to sort by some other field, then - perhaps an Autonumber. It'll
need to be some field with a value that's static from day to day.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Select Record Query 1
Two Table Query 4
Windows XP Getting Duplicate Records In Acces Report Based On Query 1
Newbie needs help with Parameter Query 4
Criteria & <> 4
Parameter Query Help 9
Query within a report 1
Union Query 1

Top