Help with limiting results.

  • Thread starter Thread starter Bill Davis
  • Start date Start date
B

Bill Davis

I think I need an If statement but I am not sure on what to do and would
appreciate any help I can get.
I have a query that pulls data from a Oracle Database and this is can be
as many at 15,000 rows. Two of the fields are [Address1] and [Access].
What I need is if [Access] = C,P or T and if the [Address1] is
different with in the 3 then show only the first record.
I hope this is not to hard to understand.
Thanks
 
Bill

We're not there, and you didn't provide a sample of the data.

Can you explain a bit more what you mean by "...if the [Address1] is
different with in the 3..."?

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
Jeff,
Sorry I was unclear before and I hope this helps.
There can be up to 15 different [Access] types but I only need C,P,T and
from there (see below) you can have a different [Address1]'s for each
[Access] so what I need in my results should be

1234A
1234C

[Address1] [Access]
1234 C
1234A C
1234 P
1234A P
1234 T
1234C T
1234 T

Thanks again
Bill


Jeff said:
Bill

We're not there, and you didn't provide a sample of the data.

Can you explain a bit more what you mean by "...if the [Address1] is
different with in the 3..."?

Regards

Jeff Boyce
Microsoft Office/Access MVP

Bill Davis said:
I think I need an If statement but I am not sure on what to do and would
appreciate any help I can get.
I have a query that pulls data from a Oracle Database and this is can be
as many at 15,000 rows. Two of the fields are [Address1] and [Access].
What I need is if [Access] = C,P or T and if the [Address1] is different
with in the 3 then show only the first record.
I hope this is not to hard to understand.
Thanks
 
Try (untested):

SELECT [Address1]
FROM [YourLinkedTable]
GROUP BY [Address1]
WHERE [Access] In ("C", "P", "T")

Alternatively, you can use the DISTINCT predicate like:

SELECT DISTINCT [Address1]
FROM [YourLinkedTable]
WHERE [Access] In ("C", "P", "T")

HTH
Van T. Dinh
MVP (Access)



Bill Davis said:
Jeff,
Sorry I was unclear before and I hope this helps.
There can be up to 15 different [Access] types but I only need C,P,T and
from there (see below) you can have a different [Address1]'s for each
[Access] so what I need in my results should be

1234A
1234C

[Address1] [Access]
1234 C
1234A C
1234 P
1234A P
1234 T
1234C T
1234 T

Thanks again
Bill


Jeff said:
Bill

We're not there, and you didn't provide a sample of the data.

Can you explain a bit more what you mean by "...if the [Address1] is
different with in the 3..."?

Regards

Jeff Boyce
Microsoft Office/Access MVP

Bill Davis said:
I think I need an If statement but I am not sure on what to do and would
appreciate any help I can get.
I have a query that pulls data from a Oracle Database and this is can be
as many at 15,000 rows. Two of the fields are [Address1] and [Access].
What I need is if [Access] = C,P or T and if the [Address1] is
different with in the 3 then show only the first record.
I hope this is not to hard to understand.
Thanks
 
Thanks Van it works
Try (untested):

SELECT [Address1]
FROM [YourLinkedTable]
GROUP BY [Address1]
WHERE [Access] In ("C", "P", "T")

Alternatively, you can use the DISTINCT predicate like:

SELECT DISTINCT [Address1]
FROM [YourLinkedTable]
WHERE [Access] In ("C", "P", "T")

HTH
Van T. Dinh
MVP (Access)



Bill Davis said:
Jeff,
Sorry I was unclear before and I hope this helps.
There can be up to 15 different [Access] types but I only need C,P,T and
from there (see below) you can have a different [Address1]'s for each
[Access] so what I need in my results should be

1234A
1234C

[Address1] [Access]
1234 C
1234A C
1234 P
1234A P
1234 T
1234C T
1234 T

Thanks again
Bill


Jeff said:
Bill

We're not there, and you didn't provide a sample of the data.

Can you explain a bit more what you mean by "...if the [Address1] is
different with in the 3..."?

Regards

Jeff Boyce
Microsoft Office/Access MVP

I think I need an If statement but I am not sure on what to do and would
appreciate any help I can get.
I have a query that pulls data from a Oracle Database and this is can be
as many at 15,000 rows. Two of the fields are [Address1] and [Access].
What I need is if [Access] = C,P or T and if the [Address1] is
different with in the 3 then show only the first record.
I hope this is not to hard to understand.
Thanks
 
Back
Top