Count datetime entries for each month from datetime column in SQL Server -


i have table timestamps , want count total number of timestamps each month. have following script returning results. there simpler way this?

select      substring(convert(varchar(12), dt_create, 112), 0, 7) month,     count(substring(convert(varchar(12), dt_create, 112), 0, 7)) signups      table_name group      substring(convert(varchar(12), dt_create, 112), 0, 7) order      1 

output

month   signups ---------------- 201705  5959 201706  9782 201707  13663 201708  7385 

characters values slower, may see increase in performance trying this.

select      year = year( dt_create ),             month = month( dt_create ),             signups = count( dt_create )        table_name   group  year( dt_create ),             month( dt_create ) ; 

Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -