in sql table following column r there
i want find 1st paid ,2nd paid,3rd paid date for same
|service_type|date |vehicle_no|
|------------|------|_---------|
|paid |23 jan|MH12H2007 |
| | | |
|paid |26 feb|MH12H2007 |
| | | |
| | | |
|paid |28 mar|MH12H2007 |
i want o/p like below
vehicle no| 1st paid date | 2nd paid date|3rd paid |latest
paid date|

pls help me out

Answers were Sorted based on User's Feedback



in sql table following column r there i want find 1st paid ,2nd paid,3rd paid date for same |servi..

Answer / sudipta santra

select distinct service_type,date,vehicle_no from
vehicle_service
where vehicle_no='MH12H2007' and service_type='paid' and
rownum<4
order by date desc

Is This Answer Correct ?    1 Yes 0 No

in sql table following column r there i want find 1st paid ,2nd paid,3rd paid date for same |servi..

Answer / vinay

friend i want o/p for multiple vehicle_no where service type
are different i.e paid ,first free,second free,third free
pls help

Is This Answer Correct ?    0 Yes 0 No

in sql table following column r there i want find 1st paid ,2nd paid,3rd paid date for same |servi..

Answer / ajit nayak

select distinct vehicle_no, wm_concat( date )
from vehicle_service
group by vehicle_no;

Is This Answer Correct ?    0 Yes 0 No

in sql table following column r there i want find 1st paid ,2nd paid,3rd paid date for same |servi..

Answer / vijay_1994

with temp as (select
service type,
paid,
vechile no,
dense_rank()over(order by date asc) as a
from table
select * from temp where a<=3;

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More SQL PLSQL Interview Questions

What are system versioned tables?

0 Answers  


table name: prod there are three fields in the table that are 1.proddate 2.prodQty 3.model Day wise prodQty is stored in the table prod write a query to display total prodqty in the year 2004 april.

2 Answers   Maruti Suzuki,


I have a Employee table with columns ename,eid,salary,deptno. How to retrieve sum of salary for each deptno?

8 Answers   L&T,


How to look at the current sql*plus system settings?

0 Answers  


What does data normalization mean?

0 Answers  






What is the diffrence between IN and EXISTS.which one is faster.

3 Answers   Infogain,


Is left join and outer join same?

0 Answers  


What is the difference between sql and isql*plus?

0 Answers  


what is purge command explain about oracle performance tuning

2 Answers   Accenture, eCentric Solutions,


how many columns can be used for creating index? : Sql dba

0 Answers  


What is difference between inner join and cross join?

0 Answers  


What is java sql driver?

0 Answers  


Categories