首页 \ 问答 \ 如何从周四到周三查询上周?(How do I query Last Week From Thursday to Wednesday?)

如何从周四到周三查询上周?(How do I query Last Week From Thursday to Wednesday?)

我试图从上周中午12:00到周三晚上中午12点从上周开始查询记录。

这需要始终运行并保持最新状态。 我从星期四到星期三对本周有另一个查询,它确实有效。 我只需要另一个查询,显示从上周过去一周后的结果。

我相信这个查询是针对上周的,但不是从周四开始到周三结束。

 SELECT collector, SUM('amountcollected') as 'totalsum' FROM commissioninfo 
   WHERE thedate >= Curdate() - INTERVAL Dayofweek(Curdate())+6 day 
   AND thedate < Curdate() - INTERVAL Dayofweek(Curdate())-1 day  
   GROUP BY collector ORDER BY totalsum DESC

I am trying to get a query to pull records from last week from thursday morning at 12:00AM to Wednesday night at 12:00pm.

This needs to always run and be current. I have another query for the current week from thursday to wednesday and it actually works. I just need another query that shows results after the week has passed from last week.

I believe this query is for last week but not starting on Thursday and ending on Wednesday.

 SELECT collector, SUM('amountcollected') as 'totalsum' FROM commissioninfo 
   WHERE thedate >= Curdate() - INTERVAL Dayofweek(Curdate())+6 day 
   AND thedate < Curdate() - INTERVAL Dayofweek(Curdate())-1 day  
   GROUP BY collector ORDER BY totalsum DESC

原文:https://stackoverflow.com/questions/27762706
更新时间:2022-07-14 12:07

最满意答案

docker-compose.yml文件格式错误,因为您没有收到任何错误,我会假设您将错误粘贴在这里,这是带有固定缩进的版本:

web:
  build: .
  volumes:
    - .:/app
  volumes_from:
    - box
  ports:
    - "3000:3000"

box:
  image: busybox
  volumes:
    - /node_modules

您的Dockerfile有一个错误,您缺少ENTRYPOINT和/或CMD节,而不是您正在使用错误意图的RUN节,这是一个工作的Dockerfile ,其中应用了修复:

FROM node:8.7.0

# The base node image sets a very verbose log level.
ENV NPM_CONFIG_LOGLEVEL warn

WORKDIR /tmp
COPY package.json /tmp/
RUN npm install

WORKDIR /app
ADD . /app
RUN cp -a /tmp/node_modules /app/

#ENV PORT=3000
EXPOSE 3000
CMD npm start

您的Dockerfile停止了Dockerfile docker-composeDockerfile映像构建阶段的执行,因为RUN npm start是一个启动并监听直到停止的进程(因为您希望它启动节点应用程序并侦听连接)导致docker-compose永远不要完成docker镜像创建步骤,更不用说其他步骤,比如创建所需的容器并完成整个docker-compose运行时进程。

简而言之:

当你使用RUN它意味着运行一个命令做一些工作并返回某个时间继续构建过程,它应该返回并退出0的代码,并且该过程将继续到下一个Dockerfile节,或者返回另一个退出代码和构建过程将失败并出现错误。

当您使用CMD您告诉docker image从此映像启动的所有容器的起始命令是什么(它也可以在运行时使用docker run覆盖)。 它与ENTRYPOINT节紧密相关,但对于基本用法,您可以使用默认安全。

进一步阅读: ENTRYPOINTCMDRUN


Your docker-compose.yml file has bad formatting, since you are not getting any errors i will assume you pasted it here wrong, here is the version with the fixed indenting:

web:
  build: .
  volumes:
    - .:/app
  volumes_from:
    - box
  ports:
    - "3000:3000"

box:
  image: busybox
  volumes:
    - /node_modules

Your Dockerfile has a bug, you are missing the ENTRYPOINT and/or CMD stanzas, instead you are using the RUN stanza with the wrong intent, here is a working Dockerfile with the fix applied:

FROM node:8.7.0

# The base node image sets a very verbose log level.
ENV NPM_CONFIG_LOGLEVEL warn

WORKDIR /tmp
COPY package.json /tmp/
RUN npm install

WORKDIR /app
ADD . /app
RUN cp -a /tmp/node_modules /app/

#ENV PORT=3000
EXPOSE 3000
CMD npm start

Your Dockerfile halted the execution of docker-compose at the docker image building stage because of the RUN npm start which is a process that starts and listens until stopped (because you want it to start your node app and listen for connections) causing docker-compose to never finish the docker image creating step, let alone the other steps like creating the needed containers and finish the entire docker-compose runtime process.

In short:

When you use RUN it is meant to run a command do some work and return sometime to continue the building process, it should return and exit code of 0 and the process will move on to the next Dockerfile stanza, or return another exit code and the building process will fail with an error.

When you use CMD you tell the docker image what is the starting command of all the containers started from this image (it can also be overridden at run time with docker run). It is tightly related to the ENTRYPOINT stanza, but for basic usage you are safe with the default.

Further reading: ENTRYPOINT, CMD and RUN

相关问答

更多
  • 是的,可以使用Nginx 在Node.js服务的不同实例之间加载平衡请求 。 每个Node.js实例都可以在不同的Docker容器中运行。 增加配置的可伸缩性就像启动另一个Docker容器并确保它在Nginx配置中注册一样简单。 (根据您更新Nginx配置的频率,可以使用各种工具/框架自动完成最后一步。) 例如,下面是一个Nginx配置,用于在不同的Node.js服务之间加载平衡传入请求。 在我们的例子中,我们在同一台机器上运行多个Node.js服务,但完全可以使用Docker容器。 文件/etc/ngin ...
  • 你可以尝试netcat或socat (它比netcat更强大) socat使用tcp4转发端口80的示例: socat tcp4-listen:80,fork tcp4:{another server}:{another port} 有关netcat的信息,请参阅http://en.wikipedia.org/wiki/Netcat#Port_Forwarding_or_Port_Mapping 两者都不是与java相关的。 You can try netcat or socat (it's more p ...
  • 查看http-proxy的自述文件 。 它有一个如何调用proxyRequest : proxy.proxyRequest(req, res, { host: 'localhost', port: 9000 }); 根据错误消息,这听起来像是您将一个伪造的域名传递给proxyRequest方法。 Take a look at the readme for http-proxy. It has an example of how to call proxyRequest: proxy.proxyRe ...
  • 您仍然可以从Docker机使用的VirtualBox访问VBoxmanage.exe命令: VBoxManage controlvm "boot2docker-vm" natpf1 "tcp-port27017,tcp,,27017,,27017"; 使用docker-machine info获取您的vm的名称。 如果vm尚未启动,请使用modifyvm 。 在这个答案中看到一个实际的例子。 这是目前的解决方法,等待将参数传递给docker-machine ssh :参见问题691 。 另一种解决方法是不 ...
  • 可能是因为您试图通过端口3000上的出站连接被阻止的网络访问您的应用程序。 大多数公司网络只允许一些特定类型的流量离开网络,通常是http(s)等。 尝试从另一个网络或不同地区的ec2-host进行测试。 It could be that you are trying to reach your application from a network in which outbound connections on port 3000 are blocked. Most corporate network o ...
  • 您docker-compose.yml文件格式错误,因为您没有收到任何错误,我会假设您将错误粘贴在这里,这是带有固定缩进的版本: web: build: . volumes: - .:/app volumes_from: - box ports: - "3000:3000" box: image: busybox volumes: - /node_modules 您的Dockerfile有一个错误,您缺少ENTRYPOINT和/或CMD节,而不是您 ...
  • 渲染函数渲染一个视图并将渲染的HTML字符串发送到客户端。查看文档 。 但是你想要存档的是先发送数据然后再发送和发送。 所以,只需删除与send线。 router.get('/users/:username', function(req, res) { var username = req.params.username; res.render('user'); }); 而且,请通过添加中间件代码来编辑您的问题并添加错误。 更新 看看你如何为用户定义你的路线。 您必须从users.js文件中删除/ ...
  • 你只能有一个进程监听一个端口,而不只是在Node.js中,但通常情况下(这里不适用的例外)。 您可以通过以下两种方法之一来实现所需: 结合节点应用程序 您可以将应用程序合并到一个应用程序中,监听一次,然后为每个主机转发请求以分离代码位 - 如果您想要实现代码分离,则代码的单独位可以是实际编写和维护的NPM模块。 使用网络服务器来代理请求 您可以在某些空闲端口(例如5000和5001)上运行2个节点进程,并使用Web服务器根据主机自动转发请求。 我推荐Nginx,因为它的代理功能相对容易设置,而且功能强大。 ...
  • 好的,我通过将Express服务器设置为侦听IP为0.0.0.0而不是127.0.0.1来解决问题。 端口转发适用于特定的网络适配器。 您会注意到,在设置中,端口转发按钮实际位于特定NIC的选项卡上。 当您的代码侦听127.0.0.1 ,它仅绑定到环回虚拟适配器。 它必须绑定到您为端口转发的网络适配器。 您可以直接绑定到该接口的地址,也可以使用0.0.0.0监听任何适配器。 完成后,您的端口转发到该特定适配器将起作用。 Ok, I resolved the problem by setting the Ex ...
  • dockerhost无法解析的原因是端口尚未发布。 使用docker run -p 8080:80 image-name启动容器映像就可以了 -p 8080:80表示“侦听主机端口8080并将这些连接转发到容器的端口80” The reason dockerhost would not resolve is because the port had not been published. Starting the container image with docker run -p 8080:80 imag ...

相关文章

更多

最新问答

更多
  • 获取MVC 4使用的DisplayMode后缀(Get the DisplayMode Suffix being used by MVC 4)
  • 如何通过引用返回对象?(How is returning an object by reference possible?)
  • 矩阵如何存储在内存中?(How are matrices stored in memory?)
  • 每个请求的Java新会话?(Java New Session For Each Request?)
  • css:浮动div中重叠的标题h1(css: overlapping headlines h1 in floated divs)
  • 无论图像如何,Caffe预测同一类(Caffe predicts same class regardless of image)
  • xcode语法颜色编码解释?(xcode syntax color coding explained?)
  • 在Access 2010 Runtime中使用Office 2000校对工具(Use Office 2000 proofing tools in Access 2010 Runtime)
  • 从单独的Web主机将图像传输到服务器上(Getting images onto server from separate web host)
  • 从旧版本复制文件并保留它们(旧/新版本)(Copy a file from old revision and keep both of them (old / new revision))
  • 西安哪有PLC可控制编程的培训
  • 在Entity Framework中选择基类(Select base class in Entity Framework)
  • 在Android中出现错误“数据集和渲染器应该不为null,并且应该具有相同数量的系列”(Error “Dataset and renderer should be not null and should have the same number of series” in Android)
  • 电脑二级VF有什么用
  • Datamapper Ruby如何添加Hook方法(Datamapper Ruby How to add Hook Method)
  • 金华英语角.
  • 手机软件如何制作
  • 用于Android webview中图像保存的上下文菜单(Context Menu for Image Saving in an Android webview)
  • 注意:未定义的偏移量:PHP(Notice: Undefined offset: PHP)
  • 如何读R中的大数据集[复制](How to read large dataset in R [duplicate])
  • Unity 5 Heighmap与地形宽度/地形长度的分辨率关系?(Unity 5 Heighmap Resolution relationship to terrain width / terrain length?)
  • 如何通知PipedOutputStream线程写入最后一个字节的PipedInputStream线程?(How to notify PipedInputStream thread that PipedOutputStream thread has written last byte?)
  • python的访问器方法有哪些
  • DeviceNetworkInformation:哪个是哪个?(DeviceNetworkInformation: Which is which?)
  • 在Ruby中对组合进行排序(Sorting a combination in Ruby)
  • 网站开发的流程?
  • 使用Zend Framework 2中的JOIN sql检索数据(Retrieve data using JOIN sql in Zend Framework 2)
  • 条带格式类型格式模式编号无法正常工作(Stripes format type format pattern number not working properly)
  • 透明度错误IE11(Transparency bug IE11)
  • linux的基本操作命令。。。