左結合で行ベースの条件を書き込む方法はありますか?左結合の行ベース条件
カラム条件に基づいていくつかの行が存在しない場合は、次の最初の行が必要です。私は以下の構造を持っている
、
create table Report
(
id int,
name varchar(10)
)
create table ReportData
(
report_id int references report(id),
flag bit,
path varchar(50)
)
insert into Report values (1, 'a');
insert into Report values (2, 'b');
insert into Report values (3, 'c');
insert into ReportData values (1, 0, 'xx');
insert into ReportData values (2, 0, 'yy');
insert into ReportData values (2, 1, 'yy');
insert into ReportData values (3, 1, 'zz');
insert into ReportData values (3, 1, 'mm');
私はあなたがこのためにROW_NUMBER
を使用することができます
1 a 0 xx
2 b 0 yy
3 c 1 zz
をレポートテーブルに各IDの一意の行がありますか? –
「列の条件に基づいて行が存在しない場合」とはどういう意味ですか?上記の例では? – GauravKP