Home > Mobile >  Filtering Data by multiple value SQL
Filtering Data by multiple value SQL

Time:12-24

i like to query/filter some data with multiple value using sql query. but i got nothing from it. here is my code.

gd = cal.get_date()
dfd = datetime.strptime(gd, '%m/%d/%y').strftime('%Y-%m-%d')

slspath = ('C:\\shgcgr\\RMWIN b4 patch 12.22.21\\SLS'   my   '.DBF')
slsdbf = DBF(slspath)
slsframe = DataFrame(iter(slsdbf))

dinerc = '1,4,5,7,8,13,14'

lunchdi = ps.sqldf("SELECT SUM(slsframe.total) AS 'netsales_for_lunch' From slsframe Where open_time >= '12:00:00' And open_time < '13:59:59' And date = '"   dfd   "'"   "And rev_center = '"   dinerc   "'")
lunchdidf = DataFrame(lunchdi)
print(lunchdidf)

thanks in advance.

CodePudding user response:

dinerc seems to be a list of rev_centers so you may need to use IN instead of = , try this:

lunchdi = ps.sqldf("SELECT SUM(slsframe.total) AS 'netsales_for_lunch' From slsframe Where open_time >= '12:00:00' And open_time < '13:59:59' And date = '"   dfd   "'"   "And rev_center IN ("   dinerc   ")")
  • Related