存在しないときに私はここに、このいずれかを把握することはできませんレコードのデータを選択するには、私のテーブル構造です:TSQL - それは
表の期間(YEARMONTHのVARCHAR(6)、weekOfMonth VARCHAR(1)、fullDate日)
表データ(SKUのvarchar型は、(6)、INT、YEARMONTHのVARCHAR(6)、fullDate日)ここに
を受けた期間のための私のデータです:これは私がしましたクエリ
yearMonth weekOfMonth fullDate
------------------------------------------
201104 1 Apr 3 2011 12:00AM
201104 1 Apr 4 2011 12:00AM
201104 1 Apr 5 2011 12:00AM
201104 1 Apr 6 2011 12:00AM
201104 1 Apr 7 2011 12:00AM
201104 1 Apr 8 2011 12:00AM
201104 1 Apr 9 2011 12:00AM
201104 2 Apr 10 2011 12:00AM
201104 2 Apr 11 2011 12:00AM
201104 2 Apr 12 2011 12:00AM
201104 2 Apr 13 2011 12:00AM
201104 2 Apr 14 2011 12:00AM
201104 2 Apr 15 2011 12:00AM
201104 2 Apr 16 2011 12:00AM
201104 3 Apr 17 2011 12:00AM
201104 3 Apr 18 2011 12:00AM
201104 3 Apr 19 2011 12:00AM
201104 3 Apr 20 2011 12:00AM
201104 3 Apr 21 2011 12:00AM
201104 3 Apr 22 2011 12:00AM
201104 3 Apr 23 2011 12:00AM
201104 4 Apr 24 2011 12:00AM
201104 4 Apr 25 2011 12:00AM
201104 4 Apr 26 2011 12:00AM
201104 4 Apr 27 2011 12:00AM
201104 4 Apr 28 2011 12:00AM
201104 4 Apr 29 2011 12:00AM
201104 4 Apr 30 2011 12:00AM
201105 1 May 1 2011 12:00AM
201105 1 May 2 2011 12:00AM
201105 1 May 3 2011 12:00AM
201105 1 May 4 2011 12:00AM
201105 1 May 5 2011 12:00AM
201105 1 May 6 2011 12:00AM
201105 1 May 7 2011 12:00AM
201105 2 May 8 2011 12:00AM
201105 2 May 9 2011 12:00AM
201105 2 May 10 2011 12:00AM
201105 2 May 11 2011 12:00AM
201105 2 May 12 2011 12:00AM
201105 2 May 13 2011 12:00AM
201105 2 May 14 2011 12:00AM
201105 3 May 15 2011 12:00AM
201105 3 May 16 2011 12:00AM
201105 3 May 17 2011 12:00AM
201105 3 May 18 2011 12:00AM
201105 3 May 19 2011 12:00AM
201105 3 May 20 2011 12:00AM
201105 3 May 21 2011 12:00AM
201105 4 May 22 2011 12:00AM
201105 4 May 23 2011 12:00AM
201105 4 May 24 2011 12:00AM
201105 4 May 25 2011 12:00AM
201105 4 May 26 2011 12:00AM
201105 4 May 27 2011 12:00AM
201105 4 May 28 2011 12:00AM
201106 1 Jun 1 2011 12:00AM
201106 1 Jun 2 2011 12:00AM
201106 1 Jun 3 2011 12:00AM
201106 1 Jun 4 2011 12:00AM
201106 1 May 29 2011 12:00AM
201106 1 May 30 2011 12:00AM
201106 1 May 31 2011 12:00AM
201106 2 Jun 5 2011 12:00AM
201106 2 Jun 6 2011 12:00AM
201106 2 Jun 7 2011 12:00AM
201106 2 Jun 8 2011 12:00AM
201106 2 Jun 9 2011 12:00AM
201106 2 Jun 10 2011 12:00AM
201106 2 Jun 11 2011 12:00AM
201106 3 Jun 12 2011 12:00AM
201106 3 Jun 13 2011 12:00AM
201106 3 Jun 14 2011 12:00AM
201106 3 Jun 15 2011 12:00AM
201106 3 Jun 16 2011 12:00AM
201106 3 Jun 17 2011 12:00AM
201106 3 Jun 18 2011 12:00AM
201106 4 Jun 19 2011 12:00AM
201106 4 Jun 20 2011 12:00AM
201106 4 Jun 21 2011 12:00AM
201106 4 Jun 22 2011 12:00AM
201106 4 Jun 23 2011 12:00AM
201106 4 Jun 24 2011 12:00AM
201106 4 Jun 25 2011 12:00AM
201106 5 Jul 1 2011 12:00AM
201106 5 Jul 2 2011 12:00AM
201106 5 Jun 26 2011 12:00AM
201106 5 Jun 27 2011 12:00AM
201106 5 Jun 28 2011 12:00AM
201106 5 Jun 29 2011 12:00AM
201106 5 Jun 30 2011 12:00AM
です試みた:
データがない場合は、毎年その月の月および週が返されません。
は、ここでは、テーブルデータのデータです:
SKU received yearMonth weekOfMonth
-------------------------------------
AAAA 5 201106 4
BBBB 1 201106 2
BBBB 1 201106 3
何があるかどうか、私はNULLまたは受信のための0のいずれかを表示したいんでしょう:
sku received yearMonth fullDate
---------------------------------------
AAAA 5 201106 Jun 23 2011 12:00AM
BBBB 1 201106 Jun 10 2011 12:00AM
BBBB 1 201106 Jun 15 2011 12:00AM
は、ここで私は2つのテーブルを結合するとき、私のデータですたとえば、
SKU received yearMonth weekOfMonth
-------------------------------------
AAAA 0 201104 1
AAAA 0 201104 2
AAAA 0 201104 3
AAAA 0 201104 4
AAAA 0 201105 1
AAAA 0 201105 2
AAAA 0 201105 3
AAAA 0 201105 4
AAAA 0 201106 1
AAAA 0 201106 2
AAAA 0 201106 3
AAAA 5 201106 4
AAAA 0 201106 5
BBBB 0 201104 1
BBBB 0 201104 2
BBBB 0 201104 3
BBBB 0 201104 4
BBBB 0 201105 1
BBBB 0 201105 2
BBBB 0 201105 3
BBBB 0 201105 4
BBBB 0 201106 1
BBBB 1 201106 2
BBBB 1 201106 3
BBBB 0 201106 4
BBBB 0 201106 5
ありがとうございます。
何歳ですか?そして、どのデータ型が「月」ですか? char(2)? – gbn
申し訳ありません私はちょうどそれを更新しました。私はそれが仕事のために列を変更する必要があります。 – pqsk
これがなぜ落とされたのか不思議です... – pqsk