954,560 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Need Help to obtain records.

Hello Guys,

I need your help to obtain this records.
I could not figure how how to do this in script.
I would like to get the RMA # 3. but the records will
pull out based on the type equal to 2 and date range..

Here is sample data:

ESN|TYPE|DATE|RMA
-----------------
123|1|2011-01-06|Null
123|3|2011-01-07|Null
123|2|2011-01-08|Null
123|11|2011-03-01|<strong>3</strong>
123|4|2011-03-17|3

the correct result:
ESN|TYPE|DATE|RMA
-----------------
123|2|2011-01-08|<strong>3</strong>


Help is greatly appreciated.

Thank you.

Jonel
jovillanuev
Junior Poster in Training
76 posts since Jun 2011
Reputation Points: 10
Solved Threads: 0
 

on what basis you chose following record for RMA
123|11|2011-03-01|3

urtrivedi
Nearly a Posting Virtuoso
1,306 posts since Dec 2008
Reputation Points: 257
Solved Threads: 270
 
on what basis you chose following record for RMA 123|11|2011-03-01|3

Hi urtrivedi,

actually by basis to get this data is using type is equal to 2 but my corncern is how to get the RMA # 3 that should be included in the result. is this possible to use the ESN to get the RMA # 3

jovillanuev
Junior Poster in Training
76 posts since Jun 2011
Reputation Points: 10
Solved Threads: 0
 

You are not getting my question. I will ask in other way round.
why you have not picked ?
123|4|2011-03-17|3

urtrivedi
Nearly a Posting Virtuoso
1,306 posts since Dec 2008
Reputation Points: 257
Solved Threads: 270
 

Cannot be. because every type there is value like the # 2 this means Shipment.
so, i will pull the data based on the Shipment which is # 2 the RMA # is NULL. my problem is how could i included in the report the RMA #3.is there any possibility?

actually i understand your question. where type # 11 the RMA value is 3.
well, the value for the type 11 is Returns, I ned the Shipment.

Regards,

Jonel

jovillanuev
Junior Poster in Training
76 posts since Jun 2011
Reputation Points: 10
Solved Threads: 0
 

Since you are not providing a clear set of rules for your query, I will improvise. You can change the criteria used on your own, or provide a clear set of rules.

select a.ESN, a.TYPE,a.DATE,b.RMA
from tablename a 
left join (select ESN, RMA from tablename 
where RMS IS NOT NULL 
and ESN ='123' 
and type =11) b 
on a.ESN = b.ESN
where ESN = '123'
and type = 2
adam_k
Practically a Posting Shark
803 posts since Jun 2011
Reputation Points: 256
Solved Threads: 149
 

adam_k's query will work well (for ESN 123). Here I am posting it without subquery and for all ESN

select a.ESN, a.TYPE,a.DATE,b.RMA
from tablename a 
left join tablename b on a.ESN=b.ESN and b.TYPE=11
where a.type = 2
urtrivedi
Nearly a Posting Virtuoso
1,306 posts since Dec 2008
Reputation Points: 257
Solved Threads: 270
 

Since you are not providing a clear set of rules for your query, I will improvise. You can change the criteria used on your own, or provide a clear set of rules.

select a.ESN, a.TYPE,a.DATE,b.RMA
from tablename a 
left join (select ESN, RMA from tablename 
where RMS IS NOT NULL 
and ESN ='123' 
and type =11) b 
on a.ESN = b.ESN
where ESN = '123'
and type = 2

Hi Adam_K.

Thank you very much. you got it. Thumbs up.

Regards,

Jonel

jovillanuev
Junior Poster in Training
76 posts since Jun 2011
Reputation Points: 10
Solved Threads: 0
 

adam_k's query will work well (for ESN 123). Here I am posting it without subquery and for all ESN

select a.ESN, a.TYPE,a.DATE,b.RMA
from tablename a 
left join tablename b on a.ESN=b.ESN and b.TYPE=11
where a.type = 2


Hi urtrivedi,

Thank you very much. Thumbs up for you.

Regards,

Jonel

jovillanuev
Junior Poster in Training
76 posts since Jun 2011
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You