首页
\
问答
\
如何获得SQL Server中两个日期之间的所有星期的开始和结束日期?(how to get the start and end dates of all weeks between two dates in SQL server?)
如何获得SQL Server中两个日期之间的所有星期的开始和结束日期?(how to get the start and end dates of all weeks between two dates in SQL server?)
我需要获取两个日期之间的所有星期开始和结束日期(星期),然后运行一个查询,返回在每个星期中插入的记录数。
declare @sDate datetime, @eDate datetime; select @sDate = '2013-02-25', @eDate = '2013-03-25'; --query to get all weeks between sDate and eDate --query to return number of items inserted in each of the weeks returned WEEK NoOfItems ----------------------------------------- 2013-02-25 5 2013-03-4 2 2013-03-11 7
I need to get all week start and end dates(weeks) between two dates and then run a query returning the number of records inserted in each of those weeks.
declare @sDate datetime, @eDate datetime; select @sDate = '2013-02-25', @eDate = '2013-03-25'; --query to get all weeks between sDate and eDate --query to return number of items inserted in each of the weeks returned WEEK NoOfItems ----------------------------------------- 2013-02-25 5 2013-03-4 2 2013-03-11 7
原文:https://stackoverflow.com/questions/15071312
更新时间:2022-05-30 12:05
最满意答案
在我看来,如果你想用
PreparedStatement
执行它们,你不能为DDL语句指定占位符(我刚刚重新创建了你试图在DDL中创建一个带占位符的简单表的问题)。It seems to me that you cannot specify placeholders for DDL statements if you want to execute them with
PreparedStatement
(I've just recreated your problem trying to create a simple table with a placeholder in the DDL).
相关问答
更多-
使用R Console,输入以下步骤以建立Teradata连接: drv = JDBC("com.teradata.jdbc.TeraDriver","ClasspathForTeradataJDBCDriverFiles") 例: drv = JDBC("com.teradata.jdbc.TeraDriver","c:\\terajdbc\\terajdbc4.jar;c:\\terajdbc\\tdgssconfig.jar") 注:UNIX机器上的路径将使用单个正斜杠来分隔其组件和文件之间 ...
-
最近有同样的问题: 如果可以,请确定导致错误的最小数据子集 将代码修改为可选择启动而无需批处理(不用于生产用途) 在我的情况下,它是一个单个数值,其精度高于它插入的列,但通常该错误消息隐藏您遇到的任何问题(字段太大?没有更多的磁盘空间?) Had the same issue recently: if you can, identify the smallest subset of data that gives you the error modify the code to be optionally ...
-
如何在Python Teradata模块PyTD中使用易失性表格(How to use Volatile Tables in Python Teradata module PyTD)[2023-12-19]
好的,感谢Teradata论坛的一些帮助,我能够解决这个问题。 您可以根据相同的结构添加尽可能多的查询: import teradata as td import pandas as pd from teradata import tdodbc udaExec = td.UdaExec (appName="dpull", version="1.0",logConsole=False) with udaExec.connect(method="ODBC",dsn="tdata", username="un" ... -
Teradata身份列和易失性/临时表问题的解决方法(Workaround for Teradata identity columns and volatile/temp tables issue)[2022-01-28]
这确实是一个奇怪的限制,即使对VarChar进行类型转换也会失败并显示相同的错误消息。 但是有一个解决方法,把选择放在派生表中: create multiset volatile table Temp_Events as ( select * from ( select es.eventSettingId, -- this is an identity column evt.lob from ForecastDevDW. ... -
根据这个: http : //www.info.teradata.com/HTMLPubs/DB_TTU_14_00/index.html#page/General_Reference/B035_1096_111A/Database.26.1905.html 非法使用标识列user_id:标识列在临时表或易失性表中定义。 它可能只在永久表中定义。 但是,还有其他方法可以在Teradata的易失性表中生成代理键,但只有在表中插入数据时才会生成,而不是在创建表时: http : //forums.teradat ...
-
这些表是Volatile Tables,这意味着您在当前会话中创建了它们,并且您可以控制它们的定义。 当您将MARBEL.graph_total_3的主索引更改为access_destino时 ,您将获得直接的AMP本地连接而无需任何准备(并且您不需要收集统计信息,因为这不会更改计划,只是估计的数字更接近现实)。 由于新的PI,表格可能会有偏差,但是当你看到Exolain时,你会发现,否则假脱机将在access_destino上有一个PI。 如果MARBEL.producto.Access_Method_I ...
-
几个小时后,我终于找到了问题。 Eclipse将所有依赖项打包到jar中 - 基本上没问题。 但是它还将Teradata JDBC驱动程序文件(tdgssconfig.jar和terajdbc4.jar)打包到结果jar中,这就是问题所在。 我调整了jar构建过程,以便不包含这些文件,并且错误消失了。 After many hours I finally found the problem. Eclipse packed all dependencies into the jar - which basic ...
-
在我看来,如果你想用PreparedStatement执行它们,你不能为DDL语句指定占位符(我刚刚重新创建了你试图在DDL中创建一个带占位符的简单表的问题)。 It seems to me that you cannot specify placeholders for DDL statements if you want to execute them with PreparedStatement (I've just recreated your problem trying to create a ...
-
Teradata锁定行访问插入查询到VOLATILE TABLE(Teradata LOCK ROW FOR ACCESS on insert query into a VOLATILE TABLE)[2023-07-22]
除非您将select放在视图中,否则我认为您不能为insert应用行锁 。 或者你切换到lock table ,但不要忘记包括所有表... 但是在大多数生产环境中,有一个包含1-1视图的数据库,包括lock row access ,你可以使用它们(或者你可能已经检查过Explain)。 I don't think you can apply a row lock for an insert unless you put the select in a view. Or you switch to lock ... -
易失性表仅在当前会话中可见。 帮助挥动表; 返回当前会话的VT列表,但是没有简单的方法可以在其他会话中获取VT的信息。 当启用此日志记录时,您可能会尝试查询DBQL或AccessLog以查找当前登录的会话提交的CREATE VOLATILE TABLE语句。 迪特 Volatile Tables are only visible within the current session. HELP VOLATILE TABLE; returns the list of VTs for the current s ...