SELECT ROW_NUMBER() OVER (
ORDER BY UsrAct_login_date
) AS Sira_No
,UsrAct_year AS Yil
,dbo.fn_YilAyTr(UsrAct_login_date) AS Ay
,User_no AS Kullanici_No
,User_name AS Kullanici_Ismi
,User_LongName AS Kullanici_Uzun_Ismi
,UsrAct_login_date AS Giris_Zamani
,CASE
WHEN YEAR(UsrAct_logout_date) < 2000
THEN NULL
ELSE UsrAct_logout_date
END AS Cikis_Zamani
,CASE
WHEN YEAR(UsrAct_logout_date) < 2000
THEN DATEDIFF(MINUTE, UsrAct_login_date, GETDATE())
ELSE DATEDIFF(MINUTE, UsrAct_login_date, UsrAct_logout_date)
END AS Kullanim_Dakikasi
,UsrAct_DBase AS Database_Kod
,VT.DB_isim AS Database_Adi
,UsrAct_IP AS Kullanici_IP_Adresi
,UsrAct_Domain AS Kullanici_Domain_Adresi
,UsrAct_PC AS Kullanici_PC_Ismi
,UsrAct_Program AS Program_Adi
,UsrAct_AktifVersiyon AS Program_Versiyonu
,UsrAct_RecInsert + UsrAct_VchrNew AS Islem_YeniKayit_Adedi
,UsrAct_RecDelete + UsrAct_VchrDelete AS Islem_Silme_Adedi
,UsrAct_RecUpdate + UsrAct_VchrUpdate AS Islem_EvrakKayitDegistirme_Adedi
,UsrAct_Menuno AS Programda_Giris_Yaptigi_MenuNo
,CASE
WHEN UsrAct_Menuno = '999999011'
THEN 'Ana Menu_ İlk Giris Ekrani '
ELSE UsrAct_AgacStr1 + ' _ ' + UsrAct_AgacStr2 + ' _ ' + UsrAct_AgacStr3 + ' _ ' + UsrAct_AgacStr4 + ' _ ' + UsrAct_AgacStr5 + ' _ ' + UsrAct_AgacStr6 + ' _ ' + UsrAct_AgacStr7 + ' _ ' + UsrAct_AgacStr8 + ' _ ' + UsrAct_AgacStr9 + ' _ ' + UsrAct_AgacStr10
END AS Programda_Giris_Yaptigi_MenuYolu
FROM MikroDB_V16.dbo.KULLANICI_AKSIYONLARI
INNER JOIN MikroDB_V16.dbo.KULLANICILAR ON UsrAct_no = User_no
INNER JOIN MikroDB_V16.dbo.VERI_TABANLARI VT ON DB_kod = UsrAct_DBase
------------------where UsrAct_DBase='AoD' /* Tek Database İçin Bu Alanı Kullanınız */
ORDER BY UsrAct_login_date DESC