0
の「イベントの連鎖」をゲット:私はこのようになりますテーブルを持つSQL
CustomerID | ContactTime | AttemptResult
-----------+-----------------+-----------------
1 | 1/1/2016 5:00 | Record Started
1 | 1/1/2016 6:00 | Appointment
2 | 1/2/2016 5:00 | Record Started
1 | 1/3/2016 6:00 | Sold
2 | 1/2/2016 5:00 | Sold
3 | 1/4/2016 5:00 | Record Started
3 | 1/4/2016 6:00 | Sold
私がために、すべての組み合わせを取得する方法でこれを照会することができますどのように
create table #temp1
(
CustomerID int,
ContactTime datetime,
Result nvarchar(50)
)
insert into #temp1 values (1, '1/1/2016 5:00', 'Record Started')
insert into #temp1 values (1, '1/1/2016 6:00', 'Appointment')
insert into #temp1 values (2, '1/2/2016 5:00', 'Record Started')
insert into #temp1 values (1, '1/3/2016 6:00', 'Sold')
insert into #temp1 values (2, '1/2/2016 5:00', 'Sold')
insert into #temp1 values (3, '1/4/2016 5:00', 'Record Started')
insert into #temp1 values (3, '1/4/2016 6:00 ', 'Sold')
からのAttemptResults?だから、のようなもの:
CustID | Sequence
-------+--------------------------------------
1 | Record Started -> Appointment -> Sold
2 | Record Started -> Sold
3 | Record Started -> Sold
私はどこから始めればさえわからないんだけど...
これは私に 'CustomerID'の近くに不正な構文があります。 ' –
私はそれを' ContactTime'によってCustomerID order by partitionに変更し、エラーを修正しましたが、結果は私が探しているものではありません。 –