Link to home
Start Free TrialLog in
Avatar of ADawn
ADawn

asked on

SQL Statement: CountOfSummaryItem

Hello All,

Is there anyway to ASC, DESC the CountOfSummaryItem in this sql?:

s_Sql = "SELECT DAuthor, Count(DAuthor) As CountOfSummaryItem, _
        (Count(*)/(Select count(*) FROM tbl_Records_DR)) as Percentage _
        From tbl_Records_DR GROUP BY DAuthor Order BY DAuthor;"

Thanks guys. ADawn
Avatar of rajaamirapu
rajaamirapu

s_Sql = "SELECT DAuthor, Count(DAuthor) As CountOfSummaryItem, _
        (Count(*)/(Select count(*) FROM tbl_Records_DR)) as Percentage _
        From tbl_Records_DR GROUP BY DAuthor Order BY CountOfSummaryItem;"
Avatar of ADawn

ASKER

rajaamirapu

I've tried this. It doesn't work! I receive the error message:

"No value given for one or maore required parameters."
Or
s_Sql = "SELECT DAuthor, Count(DAuthor) As CountOfSummaryItem, _
        (Count(*)/(Select count(*) FROM tbl_Records_DR)) as Percentage _
        From tbl_Records_DR GROUP BY DAuthor Order BY DAuthor, CountOfSummaryItem DESC;"
How are you using this sql statement? Is it part of a data environment for example?
Avatar of ADawn

ASKER

carpe-diem

Same error message:

"No value given for one or maore required parameters."

ADawn
Can you give the error code
s_Sql = "SELECT DAuthor, Count(DAuthor) As CountOfSummaryItem, _
        (Count(*)/(((Select count(*) FROM tbl_Records_DR)))) as Percentage _
        From tbl_Records_DR GROUP BY DAuthor Order BY DAuthor, CountOfSummaryItem DESC;"

Try adding extra (( )) around the subquery, I know I always use them with subqueries, otherwise errors can occur!
Don't know if this will resolve your problem.
ASKER CERTIFIED SOLUTION
Avatar of ROTRTechTeam
ROTRTechTeam

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ADawn

ASKER

ROTRTechTeam

Thanks for the great information. However, please note that you have two Order BY clauses which caused an error. I removed Order BY DAuthor (keeping: ORDER BY Count(DAuthor)) and the SQL works great.

This comment is for others that may want to use your GREAT works!

Thanks,

ADawn
Whoops!  I copied your SQL and added my order by at the end.  Sorry about that, but thanks for the compliments!  Glad it worked for you!