1. 程式人生 > >oracle,要統計一個表裡,每個頻道,每天有多少個節目並排序

oracle,要統計一個表裡,每個頻道,每天有多少個節目並排序

<select id="selectLists" resultType="map">
    	select 
		a.STARTDATE AS "startTime",
		a.CHANNELID AS "channelId",
		count(a.PROGRAMNAME) AS "programNum",
		b.CHANNELNAME AS "channelName",
		b.CHANNELNUMBER  AS "channelNumber"
		from 
		CMS_SCHEDULE a,CMS_CHANNEL b 
		where a.CHANNELID=b.CHANNELID
		
		<if test="channelId != null and channelId != ''">
			and a.CHANNELID  like CONCAT(CONCAT('%',#{channelId}),'%')
		</if>
		
		group by a.CHANNELID,a.STARTDATE,b.CHANNELNAME,b.CHANNELNUMBER
		
		order by  a.STARTDATE desc
	</select>