select - SQL count number of users hava a value > 1 -
i need select brings 2 lines, 1 number of people " number of hits " > 0 , other line number of people " number of hits " = 0
select u.name 'usuário',u.full_name 'nome usuário',count(l.referer) 'número de acessos' mmp_user u left join mmp_mmpublish_log l on u.id=l.user_id , l.event_date between '2015-08-01' , '2015-08-08' group u.name,u.full_name order count(l.referer) desc
i have, 151 users 9 accessed , 142 not accessed.
but don't return values in select, me please.
table mmp_user fields (id
,created_by
,avatar_id
,creation_date
,email
,full_name
,last_edited_by
,last_edition_date
,name
,observation
,user_password
,password_reminder
,signature
,status
,administrator
,designer
,security_office
,publisher
,branch_id
,department_id
,extension
,phone
,company_id
,position
,admission_date
,password_last_edition_date
,dismissed_date
,newsletter
,expire_date
,company
,branch
,department
,area_id
,site
,user_number
,prefix_home_phone
,prefix_mobile_phone
,address
,address_complement
,address_type
,city
,neighborhood
,state
,zip_code
,birthdate
,gender
,home_phone
,mobile_phone
,cpf
,mariage_status
,nationality
,rg
,education
,url_site
,first_name
,last_name
,id_sap
,password_gafisa
,nickname
,code_position
,creation_user_origin
,level_position
,birth_date_visibility
,home_phone_country_prefix
,home_phone_visibility
,mobile_phone_country_prefix
,mobile_phone_visibility
,area_prefix
,country_prefix
,phone_observation
,responsible
,resource_id
,avatar_rf_id
,resource_avatar_id
,avatar_url_lucene
,avatarurl
,password_exchange
,user_name_exchange
,domain_exchange
,i18n
,last_import_file
,hierarchy_position
,secret_nickname
,profile_type
,not_view_user
,change_position_date
,distinguished_name
,ou_user
,auth_token
,auth_token_expiration
)
tablemmp_mmpublish_log fields (id
,mmpublish_log_type
,event_date
,user_id
,transaction_name
,user_ip
,user_login
,user_name
,session_id
,referer
,publishing_object_id
,publishing_object_name
,phase_id
,phase_name
,phase_comment
,access_url
,home_page_id
,homepage_id
,phasecomment
,phaseid
,phasename
,po_version_number
)
thanks
you wrap query query , apply case
expression count:
select access_code, count(*) (select u.name, u.full_name, case when count(l.referer) > 0 'access' else 'no access' end access_code mmp_user u left join mmp_mmpupluish_log l on u.id=l.user_id , l.event_date between '2015-08-01' , '2015-08-08' group u.name, u.full_name) t group access_code order access_code asc
Comments
Post a Comment