次のテーブルがあります(SQL Server)テーブル名はLandParcelsです
Blockid ParcelNo Stateorprivate
========================
11001901 30 Deemana
11001901 35 Deemana
11001901 41 State
11001901 45 State
11001901 110 Private
11001901 111 Private
11001902 1 Deemana
11001902 11 State
11001902 16 Private
11002001 15 Deemana
11002001 16 State
11003001 20 Private
11002003 2 Deemana
11002003 3 State
11003003 4 Private
Blockid (数値) = Cadastral Map No に使用される最初の 6 桁と Block No の最後の 2 桁
例: 110019 は Cadastal マップ番号、01 はブロック番号です。
次のクエリを使用しました
select substring(ltrim(str(blockid)),1,6) as blockid,stateorprivate, count(*) as noofLP from LandParcels group by blockid, stateorprivate order by blockid asc
結果は
Blockid Stateorprivate noofLP
========================
110019 Deemana 2
110019 State 2
110019 Private 2
110019 Deemana 1
110019 State 1
110019 Private 1
110020 Deemana 1
110020 State 1
110020 Private 1
110020 Deemana 1
110020 State 1
110020 Private 1
レポートの次の結果を取得したい
blockid noofBlocks Deemana State Private Amt_of_Deemana_State_Private
110019 2 3 3 3 9
110020 2 2 2 2 6
これを照会する方法。助けてください。