List Info

Thread: Complicated SQL output for report




Complicated SQL output for report
country flaguser name
United States
2008-04-08 11:15:23

Hi All,
I need a little SQL hint as to how to get the desired output for a report.
 
1) Please assume I have a view  v_permit which has the data and structure like the following. This stores the information for People who have been issued a permit every month.  One person can be issued first permit, second permit, third permit based on effective dates.
  
    Title ;    First Name   ; Last Name   ; Effective date   ; End date
 ;    Mr       ; John   ;         Doe     ;         Jan 1, 2008   ;   Feb 1, 2008 
     Mr       ; John   ;         Doe     ;          feb 2, 2008   ;   Mar 1.2008
    ; Mr       ; John   ;         Doe     ;          Mar2, 2008   ;   Apri 1.2008
     Mr       ; John   ;         Doe     ;          Apr 25, 2008   June1.2008
     Ms       Nicole          Smith ;           feb1, 2008   ;    Mar 25, 2008
     Ms       Nicole          Smith ;           Apr1, 2008   ;   June 25, 2008
 ;    Ms       Nicole          Smith ;           June1, 2008   ;  Mar 25, 2008
 ;    Ms       Nicole          Smith ;           July 25, 2008   Aug 30, 2008
2) We want to write a Oracle reports and the reports parameter screens has three check boxes that allows the user to select first permit, second or third permit or a combination of all issued to every person. Evrything is based on effective date
 E.g, if the user sends First permit as a parameter, the result set should return
     Title ;    First Name   ; Last Name   ; Effective date   ; End date
     Mr       ; John   ;         Doe     ;         Jan 1, 2008   ;   Feb 1, 2008 
     Ms       Nicole          Smith ;           feb1, 2008   ;    Mar 25, 2008
 ;E.g, if the user sends Second permit as a parameter, the result set should return
     Mr       ; John   ;         Doe     ;          feb 2, 2008   ;   Mar 1.2008
    ; Ms       Nicole          Smith ;           Apr1, 2008   ;   June 25, 2008
 ;E.g, if the user sends First and Second permit as a parameters, the result set should return
      Mr       ; John   ;         Doe     ;         Jan 1, 2008   ;   Feb 1, 2008 
     ; Mr       ; John   ;         Doe     ;          feb 2, 2008   ;   Mar 1.2008
      Ms       Nicole          Smith ;           feb1, 2008   ;    Mar 25, 2008
 ;     Ms       Nicole          Smith ;           Apr1, 2008   ;   June 25, 2008
 
 
 
3) I believe, I will have to get all the records in the  result set and somehow take a count of results returned for all the persons. And then based on the parameter, some how get Ist, 2nd and third letters. But I haven't been able to figure that out.
 Can you guys help me with a little direction here
[1]

about | contact  Other archives ( Real Estate discussion Medical topics )