仅在天之间查找的SQL代码。没有日期

时间:2019-06-12 10:04:39

标签: sql hive

我正在尝试执行代码,但它引发了错误。我需要7到10天之间的时间

我已经尝试过运行它,但是到目前为止它还没有运行

select * from hive.entity.bookings_base_fact where car_number in('S424BFK',
'S275BCK',
'S257CAN',
'BANDYS',
'722YKE',
'427YNZ',
'042XUK',
'161YKD',
'029YHY',
'894VIF',
'856XHF',
'ALG16',
'364TGB',
'452YTB',
'171WSN',
'148YIC',
'599XPY',
'ZAG386',
'1LX5FU',
'1PC7PW',
'VISNOI',
'1BO1RQ',
'ZCI076',
'1LX6DH',
'ZSF986',
'1EIR205',
'1GKX072',
'RAKHRA',
'1GRK465',
'1EQO445',
'1EKU643',
'1DXD359',
'1EXA622',
'1DSJ769',
'SINGH001',
'A77027',
'1GOV986',
'1GBY431',
'1EDN031',
'1DUH537',
'1DIY218',
'WAN813',
'1DYR270',
'1ERI764',
'1DVS953',
'1GTW217',
'1GFD951',
'1ETD570',
'1GJG518',
'1GJI460',
'MIGLANI',
'1GHI708',
'1GPQ808',
'1GPT618',
'1EGF910',
'1ELU000',
'1GPP664',
'1GSF834',
'WA23600',
'1EPO234',
'1DYQ191',
'1EFG503',
'1EGK697',
'1EWY165',
'1EIX170',
'1GDP522',
'1GTP444',
'1DGF516',
'1DPC526',
'1EQM261',
'1EVC862',
'1GBX209',
'1GKZ876',
'1GNG683',
'1EEZ674',
'1GPO491',
'1EVB911',
'1GUP612',
'BV31RJ',
'CRQ71X',
'CT99PU',
'EAW37E',
'CYN07E',
'BWN62F',
'DNW45H',
'DFS57K',
'DVS85L',
'CL43PE',
'BNO46F',
'CZL21R',
'BH60VR',
'CM16EE',
'YJB08D',
'CO10RJ',
'DYW67H',
'DXL39P',
'CA10BZ',
'DWE07J',
'BV73JU',
'DPK94X',
'CJJ39S',
'CJH53E',
'CO33KZ',
'CU14BL',
'DZK23F',
'CD68JB',
'CVA62V',
'DKR25C',
'CP61CE',
'CQ55MZ',
'YCP92Y',
'DVQ94B',
'BWD26H',
'DWG35Q',
'YIV33C',
'DSN50W',
'CQ92MT',
'DXV29V',
'CHT08L',
'EAV95U',
'BN99CL',
'PTI786',
'CQ74YA',
'CK62MQ',
'CA70CH',
'CQ78UB',
'CN46RX',
'CL83WY',
'CM05DI',
'BU30HV',
'CGT93H',
'CM06TN',
'DVZ41R',
'CS35QM',
'CT03AY',
'YCP71P',
'BPI07J',
'CL43SH',
'DXV62T',
'CA99ME',
'YIU86L',
'YDE45J',
'CO96PR',
'EBN83B',
'BX19FX',
'YJK59F',
'DZB28E',
'BW50MZ',
'CK80MR',
) and year=2019 and month=06 and day between 7 and 10

3 个答案:

答案 0 :(得分:0)

我建议您将日期存储在DATE格式的日期列中,这样您就可以使用本机函数并进行如下查询:

WHERE YEAR(date) = 2019 
    AND MONTH(date) = 6 
    AND DAY(date) BETWEEN 7 AND 10

但是对于您而言,我认为您的列使用字符串,您可以这样做:

WHERE CAST(year AS INT) = 2019
        AND CAST(month AS INT) = 6
        AND CAST(day AS INT) BETWEEN 7 AND 10

答案 1 :(得分:0)

尝试通过以下方式将列转换为数据类型整数:

0               0π
0,382683432     1/16π
0,707106781     1/8π
0,923879533     3/16π
1               1/4π
0,923879533     5/16π
0,707106781     3/8π
0,382683432     7/16π
3,23114E-15     1π
-0,382683432    1 1/16π
-0,707106781    1 1/8π
-0,923879533    1 3/16π
-1              1 1/4π
-0,923879533    1 5/16π
-0,707106781    1 3/8π
-0,382683432    1 7/16π
-6,46228E-15    2π

答案 2 :(得分:0)

在整数中使用前导零表示该列实际上是字符串。如果是这种情况,则比较应为字符串:

year = '2019' and month = '06' and
day between '07' and '10'