私は以下のSQLクエリを使用していますが、 "Last Update Date"列が01/01/2016以上のレコードのみを取得したいとします。基本的には2016年のレコードのみです。以下のクエリを使用するとエラーは発生しませんが、2016年だけでなくすべての日付が返されます。構文に問題はありますか?SQL - より大きい日付クエリが機能しない
SELECT
NPI,
[Entity Type Code],
[Replacement NPI],
[Employer Identification Number (EIN)],
[Provider Organization Name (Legal Business Name)],
[Provider Last Name (Legal Name)],
[Provider First Name],
[Provider Middle Name],
[Provider Name Prefix Text],
[Provider Name Suffix Text],
[Provider Credential Text],
[Provider Other Organization Name],
[Provider Other Organization Name Type Code],
[Provider Other Last Name],
[Provider Other First Name],
[Provider Other Middle Name],
[Provider Other Name Prefix Text],
[Provider Other Name Suffix Text],
[Provider Other Credential Text],
[Provider Other Last Name Type Code],
[Provider First Line Business Mailing Address],
[Provider Second Line Business Mailing Address],
[Provider Business Mailing Address City Name],
[Provider Business Mailing Address State Name],
[Provider Business Mailing Address Postal Code],
[Provider Business Mailing Address Country Code (If outside U S)],
[Provider Business Mailing Address Telephone Number],
[Provider Business Mailing Address Fax Number],
[Provider First Line Business Practice Location Address],
[Provider Second Line Business Practice Location Address],
[Provider Business Practice Location Address City Name],
[Provider Business Practice Location Address State Name],
[Provider Business Practice Location Address Postal Code],
[Provider Business Practice Location Address Country Code (If outside U S)],
[Provider Business Practice Location Address Telephone Number],
[Provider Business Practice Location Address Fax Number],
[Provider Enumeration Date],
[Last Update Date]
FROM Data
WHERE ([Healthcare Provider Taxonomy Code_1] IN ('122300000X', '1223G0001X'))
AND ([Last Update Date] >= '01/01/2016')
あなたの最終更新日の列はどのデータ型ですか? –
それはvarchar(200) – user1342164
です。それはあなたの問題です。おそらく、それらが両方とも同じ形式の情報を保持するようにキャストする必要があります。 DATE – antorqs