选择查询中的语法错误 [英] Syntax Error in Select Query

查看:62
本文介绍了选择查询中的语法错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在努力创建一些报告,以查找和计算与货运相关的轮次和成本。数据是从跟踪系统收集的,我无法控制表的结构。


我试图对一些我不再拥有的大学写的查询进行基准测试访问类似的应用程序,但我遇到一些语法错误,不知道为什么。


这是我的查询到目前为止:


SELECT x_logs.alias,x_logs.time,x_logs.date,x_logs.status,x_logs.address,[x_logs.time] - (选择Max([x_logs.time])FROM x_logs AS DUP WHERE

x_logs.alias = DUP.x_logs.alias AND x_logs.date = DUP.x_logs.date AND x_logs.status = DUP.x_logs.status

WHERE((x_logs.date)介于06之间 / 15/07" And" 06/30/07"));



我想我会有问题以帮助我但是我不确定是什么提前在此列出。请问任何问题,我很乐意回答。我甚至可以发布我正在使用的一些表,如果这会有所帮助,虽然我不知道该怎么做。


提前谢谢!

I am working to create some reports that find and calculate round times and costs related to trucking. The data is gathered from a tracking system and I cannot control the structure of the table.

I am attempting to benchmark off of some queries that were written by a college that I no longer have access to for a similar application but I am running in to some syntax errors and do not know why.

Here is my query so far:

SELECT x_logs.alias, x_logs.time, x_logs.date, x_logs.status, x_logs.address, [x_logs.time]-(Select Max([x_logs.time])FROM x_logs AS DUP WHERE
x_logs.alias = DUP.x_logs.alias AND x_logs.date = DUP.x_logs.date AND x_logs.status = DUP.x_logs.status
WHERE ((x_logs.date) Between "06/15/07" And "06/30/07"));


I imagine there will be questions in order to help me however I am not sure what to list here in advance. Please ask any questions and I will happily answer. I can even post some of the table I''m working with if that will help, although I am not sure how to do so.

Thanks in advance!

推荐答案

您好


查询有很多想法,但是您需要了解更多信息。


你是否真的试图从时间中减去最大时间,这将给出负时间!?


我假设这都是基于一张桌子。


我最好(狂野)的猜测是


SELECT x_logs.alias,x_logs.time,x_logs.date,x_logs.status ,x_logs.address,[x_logs.time] -DUP.MaxTime FROM x_logs.alias INNER JOIN [选择x_logs.alias,x_logs.status,Max([x_logs.time]为MaxTime FROM x_logs GROUP BY .x_logs.alias,x_logs。状态] .DAD ON ON

x_logs.alias = DUP.alias AND x_logs.status = DUP.x_logs.status

WHERE((x_logs.date)介于#06 / 15/07#和#06/30/07#));


我必须发誓这是猜测,需要更多信息。


MTB
Hi

There are a number of think wrong with the query, but more information is required on what you are trying to achieve.

Are you really trying to subtract the Max time from the time, this will give negative time !?

I assume this is all based on one table.

My best (wild) guess is

SELECT x_logs.alias, x_logs.time, x_logs.date, x_logs.status, x_logs.address, [x_logs.time]-DUP.MaxTime FROM x_logs.alias INNER JOIN [Select x_logs.alias, x_logs.status, Max([x_logs.time] as MaxTime FROM x_logs GROUP BY .x_logs.alias, x_logs.status]. AS DUP ON
x_logs.alias = DUP.alias AND x_logs.status = DUP.x_logs.status
WHERE ((x_logs.date) Between #06/15/07# And #06/30/07#));

I must stress this is olny a guess and much more information is required.


MTB


非常感谢您的回复。


我在From子句中遇到语法错误。


请告诉我需要哪些其他信息。我将尝试添加一些信息,但任何有助于我了解您需要知道的问题都将受到赞赏。


该表来自我已链接到的自动数据收集系统使用ODBC。我相信它的基于foxpro。有没有办法粘贴到这个帖子的一些表格?


无论如何,记录是在卡车旅行时创建的。从几个记录到十个左右的任何地方的一组将构成一次往返的信息。它记录到达物料来源,离开物料来源,到达工作地点,并离开工作地点。它还记录了他们正在处理的工作号码。


最后,我正在寻找往返的每个部分所花费的时间。因此,我希望报告能够告诉我他们前往物质来源需要多长时间,他们在那里待了多长时间,他们上班的时间,工作时间以及整个往返时间有多长总计。


这对你有帮助吗?你知道为什么我在From子句中得到语法错误吗?


再次感谢!
Thank you very much for the reply.

I am getting a Syntax Error in the From Clause.

Please let me know what additional information is necessary. I will attempt to add some information, but any questions that help me know what you need to know would be appreciated.

The table comes from a automated data collection system that I have linked into using ODBC. I believe its foxpro based. Is there a way to paste into this posting some of the table?

Anyway, the records are created as the trucks travel about. A group of anywhere from a couple of records to ten or so will constitute one round trips worth of information. It records when the arrive at the material source, leave the material source, arrive at the job location, and leave the job location. It also records the job number they are working on.

In the end I am looking for the length of time each part of the round trip took. So I want the report to show me how long they took to travel to the material source, how long they were there, how long they took to travel to the job, how long they were at the job, and how long the whole round trip totaled.

Does that help any? Do you know why I''m getting the Syntax Error in the From Clause?

Thanks Again!





现在必须破折号,直到星期一,但是什么是错误消息(或者只是语句中的语法错误)。


如果从一个表中输入此信息/查询你能列出相关领域吗?


我假设日期是一个只有日期的日期/时间;和时间是一个只有时间的日期/时间(旅行开始一天,然后完成下一个?)


你如何区分卡车(哪个领域);你如何区分工作和旅行(哪个领域)等?


MTB
Hi

Must dash now untill Monday, but what is the Error Message (or is just Syntax error on from clause).

If this info/query in from one table can you list the relevant fields ie

I assume Date is a date/time with just the date; and Time is a date/time with just the time (do trips start one day and finish the next?)

How do you differentiate between trucks (which field); how do you differentiate between jobs and trips (which field) etc?


MTB


这篇关于选择查询中的语法错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆