 |
อยากถามผู้รู้ ครับ ... SELECT * FROM (SELECT u.GroupName, Count(MONTH(r.AcctStartTime)) AS Jan, |
|
 |
|
|
 |
 |
|
SELECT *
FROM (SELECT u.GroupName,
Count(MONTH(r.AcctStartTime)) AS Jan,
Count(MONTH(r.AcctStartTime)) AS Feb,
Count(MONTH(r.AcctStartTime)) AS Mar,
Count(MONTH(r.AcctStartTime)) AS Apr,
Count(MONTH(r.AcctStartTime)) AS May,
Count(MONTH(r.AcctStartTime)) AS Jun,
Count(MONTH(r.AcctStartTime)) AS Jul,
Count(MONTH(r.AcctStartTime)) AS Aug,
Count(MONTH(r.AcctStartTime)) AS Sep,
Count(MONTH(r.AcctStartTime)) AS Oct,
Count(MONTH(r.AcctStartTime)) AS Nov,
Count(MONTH(r.AcctStartTime)) AS Dece
FROM radacct r ,usergroup u
where r.UserName = u.UserName
Group by u.GroupName) subq
ผลลัพธ์
มันจะแสดงการเข้าใช้ ทั้งหมดที่มีอยู่ภายในฐานข้อมูลนะครับ จะมีไหมครับ ที่ต้องการแยกออกเป็นแต่ล่ะ เดือนนะครับในปี นั้นๆด้วยครับผม ไม่รู้จะเขียนโค๊ดยังไงแล้วครับ อยากจะถามผู้รู้นะครับ
Tag : - - - -
|
|
 |
 |
 |
 |
Date :
2009-04-02 10:03:44 |
By :
ragnaroknong |
View :
1331 |
Reply :
6 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เออคือว่าน่ะ ที่เห็นมันมีแต่เดือน หรือผมมองไม่ออกหรือเปล่าไม่ทราบตอบตามที่เห็นน่ะครับ
มีแต่เดือนไม่มีปี แล้วจะแยกเดือนตามปีได้อย่างไรครับ 
ควรจะมีปีด้วน่ะครับ
|
 |
 |
 |
 |
Date :
2009-04-02 12:50:21 |
By :
arsachi |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมไม่แน่ใจว่าจะตอบยังไงดี ศึกษาเรื่อง case when ดูนะครับ
|
 |
 |
 |
 |
Date :
2009-04-03 00:06:01 |
By :
plakrim |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
try on this:
select
user_name,
case dat
when '1' then 'Jan'
when '2' then 'Feb'
when '3' then 'Mar'
when '4' then 'Apr'
when '5' then 'May'
when '6' then 'Jun'
when '7' then 'Jul'
when '8' then 'Aug'
when '9' then 'Sep'
when '10' then 'Oct'
when '11' then 'Nov'
when '12' then 'Dece'
end 'date',
cnt
from
(
select UserName, dat, count(dat) as cnt
from
(
Select
UserName, MONTH(AcctStartTime) as dat
from radacct
where year(AcctStartTime) ='2008'
) a
group by UserName, dat
) as result order by 1, 2
|
 |
 |
 |
 |
Date :
2009-05-05 16:19:39 |
By :
Oriya |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
I think it is work 
|
 |
 |
 |
 |
Date :
2009-05-05 16:34:32 |
By :
Oriya |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
select
username,
case dat
when '1' then 'Jan'
when '2' then 'Feb'
when '3' then 'Mar'
when '4' then 'Apr'
when '5' then 'May'
when '6' then 'Jun'
when '7' then 'Jul'
when '8' then 'Aug'
when '9' then 'Sep'
when '10' then 'Oct'
when '11' then 'Nov'
when '12' then 'Dece'
end 'date',
cnt
from
(
select UserName, dat, count(dat) as cnt
from
(
Select
UserName, MONTH(AcctStartTime) as dat
from radacct
where year(AcctStartTime) ='2008'
) a
group by UserName, dat
) as result order by 1, 2
|
 |
 |
 |
 |
Date :
2009-05-05 16:38:32 |
By :
Oriya |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
 
|
 |
 |
 |
 |
Date :
2009-05-05 17:14:45 |
By :
kanowan |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|