473,320 Members | 1,744 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

How to count the number of letters between two same values for a column in a table.

Col1 Col2 Col3 Col4 Col5
Pravin 6 XYZ test Address
Pravin 4 PQR test Address
Pravin 3 hkkh test Address
Pravin 3.2 PQR test Address
Pravin 7.2 jhhkhkh test Address
Pravin 2.5 bbmbmb test Address
Pravin 2.5 PQR test Address
Pravin 3.2 PEN test Address

I have this table.In Col3, 2nd row i have a value PQR(which is the first appearance of this value) and in the second last row in the same column i have again PQR(which is the last appearance of this value). I have to calculate the number of letters between these two values, traversing from col4,col5, col1, col2 and so on till we reach col3 of 2nd last row(last appearance of PQR).

Any help would be appreciated.
Apr 24 '10 #1
3 1423
GaryTexmo
1,501 Expert 1GB
What do you have so far?

If you haven't done it already, your first step should be to identify the first and last rows that contain your target value.
Apr 24 '10 #2
@GaryTexmo
Thx for the reply Gary.
I haven't done it yet, because i am not sure about the approach.Can you help me in a sample code(or a psuedo) for this.
Apr 24 '10 #3
GaryTexmo
1,501 Expert 1GB
I'll do my best to help you work though it, but I won't give you any sample code, at least not until you start writing your own code for it.

As I said, what you need to do is programatically identify the first and last rows that contain your target value. Thlintoq often says around here, the best way to attack a problem is to start simple. There's a lot of wisdom in that stance... lets imagine a list of strings and we want to find the index of the first and last occurrence of a particular string in that list.

Imagine the list...

"pig", "chicken", "cow", "chicken", "pig", "horse", "duck", "cow", "horse", "cow", "cow", "cow", "sheep", "chicken", "cow", "pig"

You have this list, now you need to process it. That's your first step. The second step is to identify the first occurrence of something, lets say "cow". Thirdly, you need to determine the last occurrence of "cow".

(I'm sorry, I can't provide you with the code as not only would it violate the rules of this forum, but you wouldn't take anything away from this. I could give you the answer, but what about when the next problem comes along? You need to learn to think for yourself and solve your own problems. It doesn't mean you can't get help, but it does mean you can't just have answers)
Apr 25 '10 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Hari Om | last post by:
Here are the details of my error log files: I execute the command and get following message at console: ---------------------------------------------------------------------- ../sqlldr...
5
by: Yellowbird | last post by:
Hi all, I'm new to JavaScript, but am pretty sure what I want to accomplish is not that difficult. I just need an example or suggestion to help clarify it for me - I haven't had much time to...
22
by: Joseph Shraibman | last post by:
On a 7.3.4 database: explain analyse select count(*) from elog; Aggregate (cost=223764.05..223764.05 rows=1 width=0) (actual time=81372.11..81372.11 rows=1 loops=1) -> Seq Scan on elog ...
4
by: vacataire testeur de site web | last post by:
Bonjour je cherche à afficher de count de tables identiques dans la forme exemple num_cli | nombre de poste | nombre de voiture 1 1 3 2 2 ...
0
by: tania | last post by:
i have this table in my database: CREATE TABLE FILM( F_ID INT(5) NOT NULL AUTO_INCREMENT, F_TITLE VARCHAR(40) NOT NULL, DIRECTOR_FNAME VARCHAR(20) NOT NULL, DIRECTOR_LNAME VARCHAR(20) NOT NULL,...
2
by: DrewKull | last post by:
Ok ... so I'm looking at a query where im trying to show a bunch of columns counted up based on criteria ... So far i've been able to count all the rows up and show them ... and also count up...
1
by: jmarr02s | last post by:
The database I am working with contains a field with as many as 12 different values (09,10,11,12,13,14,15,16,17,18,19,20) My end user has requested that the number of times these 12 different...
1
by: jmarr02s | last post by:
I used the following query supplied by Jorn, SELECT IIf(=15 Or =19, "15 og 19",IIf(=13 Or =17,"13 og 17",IIf(=16 Or =20,"16 og 20",IIf(=14 Or =18,"14 og 18",IIf(=9, "9",...
2
by: Pete | last post by:
I need to create a single query (Not a SQL query) against a single table that counts the number of records in the table, where the single field "tmp" contains specific string values If the field...
1
by: Tjwapa | last post by:
How do i convert a column with id letters in a file to a number 1 or 0 in coldfusion output....for example 'CON' or 'BUS' to be converted to an output of '0'and '1' (0 to represent CON and 1 for...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.