Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Crystal PthPercentile vs Oracle percentile Post Reply Post New Topic
Author Message
jiezhangliu
Newbie
Newbie


Joined: 24 May 2010
Location: United States
Online Status: Offline
Posts: 1
Quote jiezhangliu Replybullet Topic: Crystal PthPercentile vs Oracle percentile
     Posted: 01 Jul 2011 at 5:45am
Hi Crystal expert,
I need help. I used PthPercentile in Crystal report but got different result vs Oracle percentile function.
For example:
Our data in a table like
dept      num  
  1        0.1069
  2        0.1182
  3        0.0658
  4        0.1045
I would like to find 33% low and 66% high values.
But Crystal returns 0.085 low and 0.1126 high when I used PthPercentile function:
low := PthPercentile (33, {@%num});
high := PthPercentile (66, {@%num});
And Oracle SQL returns 0.1045 low and 0.1069 high when I used percentile function:
Percentile_DISC(0.33) WITHIN GROUP(ORDER BY num ASC) OVER (PARTITION BY dept) low,
Percentile_DISC(0.66) WITHIN GROUP(ORDER BY num ASC) OVER (PARTITION BY dept) high
Please help me to have right Oracle SQL to match the Crystal result.
Thanks a lot for any help.
Jeanne
IP IP Logged
hilfy
Admin Group
Admin Group
Avatar

Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Quote hilfy Replybullet Posted: 06 Jul 2011 at 12:21pm
Are you using tables in your report (i.e, you select tables and then Crystal sets up the joins and creates the SQL) or are you using commands (i.e., you write the SQL).
 
If you're using tables, you could try creating SQL Expressions for low and high where you'll enter the "Percentile_DISC" command.  Make sure you have turned on "Perform Grouping on Server" for the report.  This may or may not work - I've not used SQL Expressions for statements that require the "Group By" clause in Crystal.
 
-Dell
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum