全て、
次のクエリがあり、期待どおりに結果セットが作成されますが、実際のレコードはすべて行番号 1 で返されます。偽のレコードのように、行番号が増加することを期待していました (コードと結果を見れば、私の言いたいことがわかるでしょう。)
Declare @FakeEquipment TABLE(
EquipmentID varchar(25),
EquipmentDesc varchar(150),
TrackingID varchar(25))
Insert into @FakeEquipment values( 'aaaa01',NULL,'zzz01')
Insert into @FakeEquipment values( 'aaaa02',NULL,'zzz01')
Insert into @FakeEquipment values( 'aaaa03',NULL,'zzz01')
Insert into @FakeEquipment values( 'aaaa04',NULL,'zzz01')
Insert into @FakeEquipment values( 'aaaa05',NULL,'zzz01')
Insert into @FakeEquipment values( 'aaaa06',NULL,'zzz01')
Insert into @FakeEquipment values( 'aaaa07',NULL,'zzz01')
Insert into @FakeEquipment values( 'aaaa08',NULL,'zzz01')
Insert into @FakeEquipment values( 'aaaa09',NULL,'zzz01')
Insert into @FakeEquipment values( 'aaaa10',NULL,'zzz01')
Insert into @FakeEquipment values( 'aaaa01',NULL,'zzz02')
Insert into @FakeEquipment values( 'aaaa02',NULL,'zzz02')
Insert into @FakeEquipment values( 'aaaa03',NULL,'zzz02')
Insert into @FakeEquipment values( 'aaaa04',NULL,'zzz02')
Insert into @FakeEquipment values( 'aaaa05',NULL,'zzz02')
Insert into @FakeEquipment values( 'aaaa06',NULL,'zzz02')
Insert into @FakeEquipment values( 'aaaa07',NULL,'zzz02')
Insert into @FakeEquipment values( 'aaaa08',NULL,'zzz02')
Insert into @FakeEquipment values( 'aaaa09',NULL,'zzz02')
Insert into @FakeEquipment values( 'aaaa10',NULL,'zzz02')
Insert into @FakeEquipment values( 'aaaa01',NULL,'zzz03')
Insert into @FakeEquipment values( 'aaaa02',NULL,'zzz03')
Insert into @FakeEquipment values( 'aaaa03',NULL,'zzz03')
Insert into @FakeEquipment values( 'aaaa04',NULL,'zzz03')
Insert into @FakeEquipment values( 'aaaa05',NULL,'zzz03')
Insert into @FakeEquipment values( 'aaaa06',NULL,'zzz03')
Insert into @FakeEquipment values( 'aaaa07',NULL,'zzz03')
Insert into @FakeEquipment values( 'aaaa08',NULL,'zzz03')
Insert into @FakeEquipment values( 'aaaa09',NULL,'zzz03')
Insert into @FakeEquipment values( 'aaaa10',NULL,'zzz03')
Insert into @FakeEquipment values( 'aaaa01',NULL,'zzz04')
Insert into @FakeEquipment values( 'aaaa02',NULL,'zzz04')
Insert into @FakeEquipment values( 'aaaa03',NULL,'zzz04')
Insert into @FakeEquipment values( 'aaaa04',NULL,'zzz04')
Insert into @FakeEquipment values( 'aaaa05',NULL,'zzz04')
Insert into @FakeEquipment values( 'aaaa06',NULL,'zzz04')
Insert into @FakeEquipment values( 'aaaa07',NULL,'zzz04')
Insert into @FakeEquipment values( 'aaaa08',NULL,'zzz04')
Insert into @FakeEquipment values( 'aaaa09',NULL,'zzz04')
Insert into @FakeEquipment values( 'aaaa10',NULL,'zzz04')
Insert into @FakeEquipment values( 'aaaa01',NULL,'zzz05')
Insert into @FakeEquipment values( 'aaaa02',NULL,'zzz05')
Insert into @FakeEquipment values( 'aaaa03',NULL,'zzz05')
Insert into @FakeEquipment values( 'aaaa04',NULL,'zzz05')
Insert into @FakeEquipment values( 'aaaa05',NULL,'zzz05')
Insert into @FakeEquipment values( 'aaaa06',NULL,'zzz05')
Insert into @FakeEquipment values( 'aaaa07',NULL,'zzz05')
Insert into @FakeEquipment values( 'aaaa08',NULL,'zzz05')
Insert into @FakeEquipment values( 'aaaa09',NULL,'zzz05')
Insert into @FakeEquipment values( 'aaaa10',NULL,'zzz05')
Insert into @FakeEquipment values( 'aaaa01',NULL,'zzz06')
Insert into @FakeEquipment values( 'aaaa02',NULL,'zzz06')
Insert into @FakeEquipment values( 'aaaa03',NULL,'zzz06')
Insert into @FakeEquipment values( 'aaaa04',NULL,'zzz06')
Insert into @FakeEquipment values( 'aaaa05',NULL,'zzz06')
Insert into @FakeEquipment values( 'aaaa06',NULL,'zzz06')
Insert into @FakeEquipment values( 'aaaa07',NULL,'zzz06')
Insert into @FakeEquipment values( 'aaaa08',NULL,'zzz06')
Insert into @FakeEquipment values( 'aaaa09',NULL,'zzz06')
Insert into @FakeEquipment values( 'aaaa10',NULL,'zzz06')
Insert into @FakeEquipment values( 'aaaa01',NULL,'zzz07')
Insert into @FakeEquipment values( 'aaaa02',NULL,'zzz07')
Insert into @FakeEquipment values( 'aaaa03',NULL,'zzz07')
Insert into @FakeEquipment values( 'aaaa04',NULL,'zzz07')
Insert into @FakeEquipment values( 'aaaa05',NULL,'zzz07')
Insert into @FakeEquipment values( 'aaaa06',NULL,'zzz07')
Insert into @FakeEquipment values( 'aaaa07',NULL,'zzz07')
Insert into @FakeEquipment values( 'aaaa08',NULL,'zzz07')
Insert into @FakeEquipment values( 'aaaa09',NULL,'zzz07')
Insert into @FakeEquipment values( 'aaaa10',NULL,'zzz07')
Insert into @FakeEquipment values( 'aaaa01',NULL,'zzz08')
Insert into @FakeEquipment values( 'aaaa02',NULL,'zzz08')
Insert into @FakeEquipment values( 'aaaa03',NULL,'zzz08')
Insert into @FakeEquipment values( 'aaaa04',NULL,'zzz08')
Insert into @FakeEquipment values( 'aaaa05',NULL,'zzz08')
Insert into @FakeEquipment values( 'aaaa06',NULL,'zzz08')
Insert into @FakeEquipment values( 'aaaa07',NULL,'zzz08')
Insert into @FakeEquipment values( 'aaaa08',NULL,'zzz08')
Insert into @FakeEquipment values( 'aaaa09',NULL,'zzz08')
Insert into @FakeEquipment values( 'aaaa10',NULL,'zzz08')
Insert into @FakeEquipment values( 'aaaa01',NULL,'zzz09')
Insert into @FakeEquipment values( 'aaaa02',NULL,'zzz09')
Insert into @FakeEquipment values( 'aaaa03',NULL,'zzz09')
Insert into @FakeEquipment values( 'aaaa04',NULL,'zzz09')
Insert into @FakeEquipment values( 'aaaa05',NULL,'zzz09')
Insert into @FakeEquipment values( 'aaaa06',NULL,'zzz09')
Insert into @FakeEquipment values( 'aaaa07',NULL,'zzz09')
Insert into @FakeEquipment values( 'aaaa08',NULL,'zzz09')
Insert into @FakeEquipment values( 'aaaa09',NULL,'zzz09')
Insert into @FakeEquipment values( 'aaaa10',NULL,'zzz09')
Insert into @FakeEquipment values( 'aaaa01',NULL,'zzz10')
Insert into @FakeEquipment values( 'aaaa02',NULL,'zzz10')
Insert into @FakeEquipment values( 'aaaa03',NULL,'zzz10')
Insert into @FakeEquipment values( 'aaaa04',NULL,'zzz10')
Insert into @FakeEquipment values( 'aaaa05',NULL,'zzz10')
Insert into @FakeEquipment values( 'aaaa06',NULL,'zzz10')
Insert into @FakeEquipment values( 'aaaa07',NULL,'zzz10')
Insert into @FakeEquipment values( 'aaaa08',NULL,'zzz10')
Insert into @FakeEquipment values( 'aaaa09',NULL,'zzz10')
Insert into @FakeEquipment values( 'aaaa10',NULL,'zzz10')
Select
Equipment_EquipmentID,
Equipment_Description,
JobAccount_TrackingID
,row as rowcnt
from
(
Select row_number() over (partition by Equipment_EquipmentID order by JobAccount_TrackingID) row,*
from
(SELECT DISTINCT
CustomizedFieldLogEquipmentJobAccount_1.Equipment_EquipmentID,
CustomizedFieldLogEquipmentJobAccount_1.Equipment_Description,
CustomizedFieldLogEquipmentJobAccount_1.JobAccount_TrackingID
FROM
CustomizedFieldLogEquipmentJobAccount AS CustomizedFieldLogEquipmentJobAccount_1 INNER JOIN CustomizedAccount ON CustomizedFieldLogEquipmentJobAccount_1.Account_AccountID = CustomizedAccount.AccountID
WHERE
(CustomizedAccount.AppliesToEquipment = 1)
AND
(CustomizedFieldLogEquipmentJobAccount_1.FieldLog_FieldLogID =1219)
AND
IsRented = 0
AND
isnumeric(right(CustomizedFieldLogEquipmentJobAccount_1.JobAccount_TrackingID,1))=1
union
select
EquipmentID,
EquipmentDesc,
TrackingID
from @FakeEquipment) a
)b
Group By
Equipment_EquipmentID,
Equipment_Description,
JobAccount_TrackingID
,row
order by Equipment_EquipmentID
次のような結果が返されます。
Equipment_EquipmentID Equipment_Description JobAccount_TrackingID rowcnt
1218 PAVER 0441-01409 1
127 Ford F250 Pick-Up 0441-01409 1
1350 PNEUMATIC ROLLER 0441-01409 1
1354 VIBRATORY PUP ROLLER 0441-01409 1
1445 JOHN DEERE SKIP 0441-01409 1
16-003 FORD F-350 0441-01409 1
30 F550 CREW TRUCK 0441-01409 1
3-007 TRAFFIC CONTROL F-550 0441-01409 1
6-002 CAT PAVING ROLLER 0441-01409 1
6-006 CAT PAVING ROLLER 0441-01409 1
aaaa01 NULL zzz01 1
aaaa01 NULL zzz02 2
aaaa01 NULL zzz03 3
aaaa01 NULL zzz04 4
aaaa01 NULL zzz05 5
aaaa01 NULL zzz06 6
aaaa01 NULL zzz07 7
aaaa01 NULL zzz08 8
aaaa01 NULL zzz09 9
aaaa01 NULL zzz10 10
ご覧のとおり、偽の機器テーブルのレコードはすべて正しい行番号を持っていますが、実際のレコードはすべて行番号 1 を持っています。
私がやろうとしているのは、レコード セットを 2 つの SSRS 2005 マトリックス コントロールに分割して、それぞれに 6 つのレコード (最大 12) があるようにすることですが、それはできません。この方向の助けをいただければ幸いです。