doc_jay
asked on
MYSQL - select help with grouping totals
MYSQL 5.6.22
Hi,
I'm hoping I can get this query to group my totals correctly.
- All of the data I need to search for lives in one table -
this result comes back with:
I would like for the results to show the site with the most 'counts' to be at the top of the list.
Hi,
I'm hoping I can get this query to group my totals correctly.
- All of the data I need to search for lives in one table -
select max(study_custom1) as 'Outside Institution', COUNT(study_custom1) as 'Number of Studies'
from pacsdb.study
where accession_no like '%OUT%'
and study_custom1 is not null
and created_time >= DATE_FORMAT( CURRENT_DATE - INTERVAL 1 MONTH, '%Y/%m/01' )
AND created_time < DATE_FORMAT( CURRENT_DATE, '%Y/%m/01' )
group by study_custom1
order by 'Number of Studies' DESC
this result comes back with:
site3 5
site2 8
site8 2
site4 1
site1 12
I would like for the results to show the site with the most 'counts' to be at the top of the list.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER