aftabn10 Posted April 8, 2009 Share Posted April 8, 2009 I have written the following query that returns the top 10 items from a column. I am looking to change this to give me the top 10 Percentage from the same column but dont know how to change my query. Could somebody please help. The following is my query: SELECT "TEST AHT By Agent".RootirID saw_0, "TEST RE Values Dim"."Queue Name" saw_1, "TEST AHT By Agent"."Agent ID" saw_2, "TEST AHT By Agent"."AHT -OM" saw_3 FROM Genesys_TEST WHERE ("TEST RE Values Dim"."Queue Name" LIKE 'Queue 1 ') AND (TOPN("TEST AHT By Agent"."AHT -OM", 10) <= 10) ORDER BY saw_0, saw_1, saw_2 Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/153154-top-10-percent/ Share on other sites More sharing options...
Yesideez Posted April 8, 2009 Share Posted April 8, 2009 Top 10% of what exactly? I might be very wrong but my first thoughts are to add a new field to your database and populate it with the percentages for each record then you can do a simple ORDER BY percentage DESC LIMIT 0,10 type query. Quote Link to comment https://forums.phpfreaks.com/topic/153154-top-10-percent/#findComment-804514 Share on other sites More sharing options...
aftabn10 Posted April 8, 2009 Author Share Posted April 8, 2009 Thanks for your reply Yesideez. Currently within my query I have the following: AND (TOPN("TEST AHT By Agent"."AHT -OM", 10) <= 10) which gives me the top 10 values within the TEST AHT By Agent column. What i would like is for it to give me the top 10% which would mean it gives me a total of 6 values as the total entries within the TEST AHT By Agent column is 56. Hope that makes sense. Thanks once again. Quote Link to comment https://forums.phpfreaks.com/topic/153154-top-10-percent/#findComment-804533 Share on other sites More sharing options...
Yesideez Posted April 8, 2009 Share Posted April 8, 2009 Are you using SQL or MySQL? I think maybe you're in the wrong forum and shold be here: http://www.phpfreaks.com/forums/index.php/board,35.0.html ...I'm pretty sure TOPN is a MSSQL command. Quote Link to comment https://forums.phpfreaks.com/topic/153154-top-10-percent/#findComment-804543 Share on other sites More sharing options...
aftabn10 Posted April 8, 2009 Author Share Posted April 8, 2009 Yesideez, currently I am using SQL. Quote Link to comment https://forums.phpfreaks.com/topic/153154-top-10-percent/#findComment-804556 Share on other sites More sharing options...
revraz Posted April 8, 2009 Share Posted April 8, 2009 SQL is a language, MSSQL, MySQL, Oracle are Database Applications. Quote Link to comment https://forums.phpfreaks.com/topic/153154-top-10-percent/#findComment-804567 Share on other sites More sharing options...
fenway Posted April 14, 2009 Share Posted April 14, 2009 Yesideez, currently I am using SQL. SQL is a language, MSSQL, MySQL, Oracle are Database Applications. That would explain the double-quotes in the other post... Quote Link to comment https://forums.phpfreaks.com/topic/153154-top-10-percent/#findComment-809675 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.