PC Review


Reply
Thread Tools Rate Thread

Can a query find info X numbr of rows from target info?

 
 
=?Utf-8?B?QW5uIFNjaGFycGY=?=
Guest
Posts: n/a
 
      23rd Nov 2005
Hi. I am running Access 2003 under Windows XP. I have a crazy looking
output file that I need to analyze. The system we are working with creates
output files that can run 3,000 - 35,000 rows long by two columns wide. Of
these rows, maybe a few hundred are relevant to our needs.

Column 1 is basically throwaway. One of the things I need to do with the
column 2 data is find information that is 1, 4 or 5 rows below a target
phrase. For example, if row 156 contains the word DUMPEND, I need to
identify the the words that appear in rows 157, 160 and 161.

I know that in Excel I could concatenate the words based on cell references.
Is there a way in Access to concatenate data based on the records' relation
to one another in the same table?

Thanks for any help you can give me.

Ann Scharpf
 
Reply With Quote
 
 
 
 
Guest
Posts: n/a
 
      23rd Nov 2005
Excel has Row and Column names, with an explicit sort order.

If you want to do something like that in Access, you need
a numeric Row index I see that you have Column (Field)
namesL: Do you have Row names (Primary Key). If you
do have a Primary Key, does it have an explicit sort order?


Start in the query design view by adding the table, selecting
the 'dumpend' records.

Then add the same table again, and join on the index field.

Then go into SQL view, and change the join from (n=n) to
(n = n-1).

select * from tbl inner join tbl as tbl1 on (tbl.pk = tbl1.pk-1)
where tbl.fld = 'dumpend'


Test as see that it is working. When happy, START AGAIN
(you can't go back to design view) with 4 joined copies of
the table, and change all 4 joins in sql view.

(david)



"Ann Scharpf" <(E-Mail Removed)> wrote in message
news:FC2D4249-5AE7-4818-94BC-(E-Mail Removed)...
> Hi. I am running Access 2003 under Windows XP. I have a crazy looking
> output file that I need to analyze. The system we are working with

creates
> output files that can run 3,000 - 35,000 rows long by two columns wide.

Of
> these rows, maybe a few hundred are relevant to our needs.
>
> Column 1 is basically throwaway. One of the things I need to do with the
> column 2 data is find information that is 1, 4 or 5 rows below a target
> phrase. For example, if row 156 contains the word DUMPEND, I need to
> identify the the words that appear in rows 157, 160 and 161.
>
> I know that in Excel I could concatenate the words based on cell

references.
> Is there a way in Access to concatenate data based on the records'

relation
> to one another in the same table?
>
> Thanks for any help you can give me.
>
> Ann Scharpf



 
Reply With Quote
 
 
 
 
=?Utf-8?B?QW5uIFNjaGFycGY=?=
Guest
Posts: n/a
 
      29th Nov 2005
Hi, David:

Thanks for your response. (I have been away for the Thanksgiving holiday
and just checked back in.)

Yes, when I import the data file, I am letting Access create an index. So
each row is sequentially numbered, giving me the desired explicit sort order.

I can see where you're going with the join (n=n-1) but I don't have that
type of statement in my SQL. I was getting a little lost translating between
my names and your example, so I renamed my data "tbl" & "fld" so I could make
an exact comparison between my SQL & your advice. This is what I'm getting:

SELECT tbl.fld
FROM tbl INNER JOIN tbl AS tbl_1 ON tbl.ID = tbl_1.ID
WHERE (((tbl.fld) Like "*dumpend*"));

I only have the one field in the table (aside from the index), so do I need
to do this part?

> select * from tbl inner join tbl as tbl1 on (tbl.pk = tbl1.pk-1)
> where tbl.fld = 'dumpend'


I didn't understand the "pk" part, as I don't see this in my SQL.

Thanks very much for taking the time to help me.

Ann

"david@epsomdotcomdotau" wrote:

> Excel has Row and Column names, with an explicit sort order.
>
> If you want to do something like that in Access, you need
> a numeric Row index I see that you have Column (Field)
> namesL: Do you have Row names (Primary Key). If you
> do have a Primary Key, does it have an explicit sort order?
>
>
> Start in the query design view by adding the table, selecting
> the 'dumpend' records.
>
> Then add the same table again, and join on the index field.
>
> Then go into SQL view, and change the join from (n=n) to
> (n = n-1).
>
> select * from tbl inner join tbl as tbl1 on (tbl.pk = tbl1.pk-1)
> where tbl.fld = 'dumpend'
>
>
> Test as see that it is working. When happy, START AGAIN
> (you can't go back to design view) with 4 joined copies of
> the table, and change all 4 joins in sql view.
>
> (david)
>
>
>
> "Ann Scharpf" <(E-Mail Removed)> wrote in message
> news:FC2D4249-5AE7-4818-94BC-(E-Mail Removed)...
> > Hi. I am running Access 2003 under Windows XP. I have a crazy looking
> > output file that I need to analyze. The system we are working with

> creates
> > output files that can run 3,000 - 35,000 rows long by two columns wide.

> Of
> > these rows, maybe a few hundred are relevant to our needs.
> >
> > Column 1 is basically throwaway. One of the things I need to do with the
> > column 2 data is find information that is 1, 4 or 5 rows below a target
> > phrase. For example, if row 156 contains the word DUMPEND, I need to
> > identify the the words that appear in rows 157, 160 and 161.
> >
> > I know that in Excel I could concatenate the words based on cell

> references.
> > Is there a way in Access to concatenate data based on the records'

> relation
> > to one another in the same table?
> >
> > Thanks for any help you can give me.
> >
> > Ann Scharpf

>
>
>

 
Reply With Quote
 
=?Utf-8?B?QW5uIFNjaGFycGY=?=
Guest
Posts: n/a
 
      29th Nov 2005
Well, duh! PK is primary key! The (n=n-1) is just explaining what the
select statement is doing.

I just had to step away from it for a minute and then it made sense.

Thanks. I will try again now that I understand what you're saying.

Ann

"Ann Scharpf" wrote:

> Hi, David:
>
> Thanks for your response. (I have been away for the Thanksgiving holiday
> and just checked back in.)
>
> Yes, when I import the data file, I am letting Access create an index. So
> each row is sequentially numbered, giving me the desired explicit sort order.
>
> I can see where you're going with the join (n=n-1) but I don't have that
> type of statement in my SQL. I was getting a little lost translating between
> my names and your example, so I renamed my data "tbl" & "fld" so I could make
> an exact comparison between my SQL & your advice. This is what I'm getting:
>
> SELECT tbl.fld
> FROM tbl INNER JOIN tbl AS tbl_1 ON tbl.ID = tbl_1.ID
> WHERE (((tbl.fld) Like "*dumpend*"));
>
> I only have the one field in the table (aside from the index), so do I need
> to do this part?
>
> > select * from tbl inner join tbl as tbl1 on (tbl.pk = tbl1.pk-1)
> > where tbl.fld = 'dumpend'

>
> I didn't understand the "pk" part, as I don't see this in my SQL.
>
> Thanks very much for taking the time to help me.
>
> Ann
>
> "david@epsomdotcomdotau" wrote:
>
> > Excel has Row and Column names, with an explicit sort order.
> >
> > If you want to do something like that in Access, you need
> > a numeric Row index I see that you have Column (Field)
> > namesL: Do you have Row names (Primary Key). If you
> > do have a Primary Key, does it have an explicit sort order?
> >
> >
> > Start in the query design view by adding the table, selecting
> > the 'dumpend' records.
> >
> > Then add the same table again, and join on the index field.
> >
> > Then go into SQL view, and change the join from (n=n) to
> > (n = n-1).
> >
> > select * from tbl inner join tbl as tbl1 on (tbl.pk = tbl1.pk-1)
> > where tbl.fld = 'dumpend'
> >
> >
> > Test as see that it is working. When happy, START AGAIN
> > (you can't go back to design view) with 4 joined copies of
> > the table, and change all 4 joins in sql view.
> >
> > (david)
> >
> >
> >
> > "Ann Scharpf" <(E-Mail Removed)> wrote in message
> > news:FC2D4249-5AE7-4818-94BC-(E-Mail Removed)...
> > > Hi. I am running Access 2003 under Windows XP. I have a crazy looking
> > > output file that I need to analyze. The system we are working with

> > creates
> > > output files that can run 3,000 - 35,000 rows long by two columns wide.

> > Of
> > > these rows, maybe a few hundred are relevant to our needs.
> > >
> > > Column 1 is basically throwaway. One of the things I need to do with the
> > > column 2 data is find information that is 1, 4 or 5 rows below a target
> > > phrase. For example, if row 156 contains the word DUMPEND, I need to
> > > identify the the words that appear in rows 157, 160 and 161.
> > >
> > > I know that in Excel I could concatenate the words based on cell

> > references.
> > > Is there a way in Access to concatenate data based on the records'

> > relation
> > > to one another in the same table?
> > >
> > > Thanks for any help you can give me.
> > >
> > > Ann Scharpf

> >
> >
> >

 
Reply With Quote
 
=?Utf-8?B?QW5uIFNjaGFycGY=?=
Guest
Posts: n/a
 
      29th Nov 2005
This is beautiful - BRILLIANT! It does EXACTLY what I need! This query is
infinitely better than the monster file I would have had to create in Excel.
Thank you so much, David!

"david@epsomdotcomdotau" wrote:

> Excel has Row and Column names, with an explicit sort order.
>
> If you want to do something like that in Access, you need
> a numeric Row index I see that you have Column (Field)
> namesL: Do you have Row names (Primary Key). If you
> do have a Primary Key, does it have an explicit sort order?
>
>
> Start in the query design view by adding the table, selecting
> the 'dumpend' records.
>
> Then add the same table again, and join on the index field.
>
> Then go into SQL view, and change the join from (n=n) to
> (n = n-1).
>
> select * from tbl inner join tbl as tbl1 on (tbl.pk = tbl1.pk-1)
> where tbl.fld = 'dumpend'
>
>
> Test as see that it is working. When happy, START AGAIN
> (you can't go back to design view) with 4 joined copies of
> the table, and change all 4 joins in sql view.
>
> (david)
>
>
>
> "Ann Scharpf" <(E-Mail Removed)> wrote in message
> news:FC2D4249-5AE7-4818-94BC-(E-Mail Removed)...
> > Hi. I am running Access 2003 under Windows XP. I have a crazy looking
> > output file that I need to analyze. The system we are working with

> creates
> > output files that can run 3,000 - 35,000 rows long by two columns wide.

> Of
> > these rows, maybe a few hundred are relevant to our needs.
> >
> > Column 1 is basically throwaway. One of the things I need to do with the
> > column 2 data is find information that is 1, 4 or 5 rows below a target
> > phrase. For example, if row 156 contains the word DUMPEND, I need to
> > identify the the words that appear in rows 157, 160 and 161.
> >
> > I know that in Excel I could concatenate the words based on cell

> references.
> > Is there a way in Access to concatenate data based on the records'

> relation
> > to one another in the same table?
> >
> > Thanks for any help you can give me.
> >
> > Ann Scharpf

>
>
>

 
Reply With Quote
 
Guest
Posts: n/a
 
      29th Nov 2005
Thank you. It is always encouraging to see something working :~)

(david)

"Ann Scharpf" <(E-Mail Removed)> wrote in message
news:E3AD451B-1005-42D2-8772-(E-Mail Removed)...
> This is beautiful - BRILLIANT! It does EXACTLY what I need! This query

is
> infinitely better than the monster file I would have had to create in

Excel.
> Thank you so much, David!
>

..


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can you place a Zero at the beginning of a numbr (Ex. D.L. #). vrogers Microsoft Excel Misc 1 18th Feb 2008 06:33 PM
Numbr of computers allowed on an XP Professional network =?Utf-8?B?Q3VycnkgS2luZw==?= Windows XP Networking 4 29th Apr 2006 01:31 AM
How to show numbr in words like (100 = One Hundred ) =?Utf-8?B?YWhhamVpZA==?= Microsoft Excel Misc 1 2nd Mar 2006 09:56 AM
How find if target is object in Worksheet_Change (ByVal Target As.. ?) Gunnar Johansson Microsoft Excel Programming 3 1st Jul 2004 09:25 PM
"Save Target as" and "Print Target" does not work Tania Windows XP Internet Explorer 2 15th Oct 2003 07:42 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:04 AM.