回答編集履歴
2
追記
test
CHANGED
@@ -12,7 +12,7 @@
|
|
12
12
|
|
13
13
|
where B.認定番号=A.認定番号
|
14
14
|
|
15
|
-
order by IIF(B.判別フラグ="-",0,1),B.日時 desc,B.番号) as 番号
|
15
|
+
order by IIF(B.判別フラグ="-",0,1),B.日時 desc,B.番号 desc) as 番号
|
16
16
|
|
17
17
|
from テーブルA as A
|
18
18
|
|
@@ -34,7 +34,7 @@
|
|
34
34
|
|
35
35
|
where B.認定番号=A.認定番号
|
36
36
|
|
37
|
-
order by IIF(B.判別フラグ="-",0,1),B.日時 desc,B.番号) as 番号
|
37
|
+
order by IIF(B.判別フラグ="-",0,1),B.日時 desc,B.番号 desc) as 番号
|
38
38
|
|
39
39
|
from テーブルA as A
|
40
40
|
|
1
追記
test
CHANGED
@@ -8,11 +8,11 @@
|
|
8
8
|
|
9
9
|
select A.*
|
10
10
|
|
11
|
-
,(select top 1 番号 from テーブルB as B
|
11
|
+
,(select top 1 B.番号 from テーブルB as B
|
12
12
|
|
13
13
|
where B.認定番号=A.認定番号
|
14
14
|
|
15
|
-
order by IIF(B.判別フラグ="-",0,1),B.日時 desc) as 番号
|
15
|
+
order by IIF(B.判別フラグ="-",0,1),B.日時 desc,B.番号) as 番号
|
16
16
|
|
17
17
|
from テーブルA as A
|
18
18
|
|
@@ -30,11 +30,11 @@
|
|
30
30
|
|
31
31
|
select A.*
|
32
32
|
|
33
|
-
,(select top 1 IIF(B.判別フラグ="-","-","") & 番号 from テーブルB as B
|
33
|
+
,(select top 1 IIF(B.判別フラグ="-","-","") & B.番号 from テーブルB as B
|
34
34
|
|
35
35
|
where B.認定番号=A.認定番号
|
36
36
|
|
37
|
-
order by IIF(B.判別フラグ="-",0,1),B.日時 desc) as 番号
|
37
|
+
order by IIF(B.判別フラグ="-",0,1),B.日時 desc,B.番号) as 番号
|
38
38
|
|
39
39
|
from テーブルA as A
|
40
40
|
|