sql >> データベース >  >> RDS >> Sqlserver

1 か月あたりのレコード数をカウントするための SQL クエリ

    あと少しです:ユーザーを選択リストに追加するだけです:

    select [Usr],
      [1] AS January,
      [2] AS February,
      [3] AS March,
      [4] AS April,
      [5] AS May,
      [6] AS June,
      [7] AS July,
      [8] AS August,
      [9] AS September,
      [10] AS October,
      [11] AS November, 
      [12] AS December 
    from
    (
    SELECT MONTH(DateVisit) AS month, [User], [User] as [Usr] FROM UserVisit
    ) AS t
    PIVOT (
    COUNT([User])
      FOR month IN([1], [2], [3], [4], [5],[6],[7],[8],[9],[10],[11],[12])
    ) p
      

    1. MySQL SELECT x FROM a WHERE NOT IN(SELECT x FROM b)-予期しない結果

    2. OracleでSQLServerのIsNull()関数に相当するものは何ですか?

    3. パケットが大きすぎる例外を解決する方法XAMPPMysql

    4. PostgreSQLDockerイメージでテーブルを作成します