我遇到了以下遗留的PL/SQL,并且发现对标量常量的外连接有些令人困惑.首先,有人可以确认我将此转换为ANSI的尝试是正确的.
遗产代码:
cursor c1item (c1item_iel_id number) is
select
`<columns>`
from iel_item iit, iel_item_property iip
where iit.iit_change_type = 'I'
and iip.iip_change_type (+) = 'I'
and iip.it_id (+) = iit.it_id
and iit.iel_id = c1item_iel_id
and iip.iel_id (+) = c1item_iel_id;
Run Code Online (Sandbox Code Playgroud)
ANSI代码
cursor c1item (c1item_iel_id number) is
select
`<columns>`
from iel_item iit
left outer join iel_item_property iip
on iip.it_id = iit.it_id
and iit.iit_change_type = 'I'
and iip.iip_change_type = 'I'
and iit.iel_id = c1item_iel_id
and iip.iel_id = c1item_iel_id;
Run Code Online (Sandbox Code Playgroud)
如果这是正确的,那么我没有看到使用外连接的意义.当然,如果表iit中的主键it_id在表iip …
我有类似的课程:
class myClass1 {
public void test() {};
class myClass2 {
public void test() {};
class myClass3 {
test();
....................
} } }
Run Code Online (Sandbox Code Playgroud)
如何确保myClass 1的方法测试而不是myClass2的方法测试?谢谢.
我遇到了一个 SQL 查询问题,该问题基本上慢到需要大约 17 分钟以上的时间。我很确定这仅仅是因为外连接和纯数据量使这个查询变得很糟糕。不幸的是,我没有看到重写它以获得我想要的东西的好方法
我有以下表格(为简洁起见省略了一些列):
Events
ID (AUTOINCREMENT INTEGER PRIMARY KEY) | Guid (16 Byte BLOB) | Time (FLOAT)
Relationships
ID (AUTOINCREMENT INTEGER PRIMARY KEY) | Parent (INTEGER) | Child (INTEGER) | ParentTable (INTEGER) | ChildTable (INTEGER)
Run Code Online (Sandbox Code Playgroud)
事件表有大约 25k 行(这可能是实际的四倍数据的)。关系表有大约 212k 行(同样,可能会翻两番)。
本质上,事件可以嵌套事件。生成的树没有深度限制(尽管目前还不是很深)。
选择事件记录时,我的目标是返回提供以下数据的数据行:
ID | Guid | Time | ParentIndex | ParentGuid
Run Code Online (Sandbox Code Playgroud)
我也完全期望根级事件将具有空的 ParentID 和 ParentGuid 列(这是我采用外连接方法的原因之一)。
我的查询(无约束)如下所示:
SELECT E.*, R.Parent as 'ParentIndex', PE.Guid AS 'ParentGuid' FROM Events AS E
LEFT OUTER JOIN Relationships AS …Run Code Online (Sandbox Code Playgroud) 我创建了这个AsyncTask内部类,现在我想把它变成外层.这是代码:
private class DownloadDataFromServer extends AsyncTask<String, Integer, String> {
ProgressDialog dialog;
boolean connErr = false;
boolean soErr = false;
@Override
protected void onPreExecute() {
dialog = new ProgressDialog(HomePage.this); !!!!PROBLEM!!!!
dialog.setIndeterminate(false);
dialog.setMax(100);
dialog.setProgressStyle(ProgressDialog.STYLE_HORIZONTAL);
dialog.setCancelable(false);
dialog.setTitle("Download");
dialog.setMessage("Updating...");
dialog.show();
super.onPreExecute();
}
@Override
protected String doInBackground(String... urls) {
// do something
}
protected void onProgressUpdate(Integer... progress) {
// Update the progress
dialog.setProgress(progress[0]);
}
@Override
protected void onPostExecute(String result) {
if (connErr || soErr) {
String msg = "Bad connection";
AlertDialog.Builder builder;
builder = new …Run Code Online (Sandbox Code Playgroud) android outer-join inner-classes android-context android-asynctask
我有三张表:
clinic = (id,name,short_name,region,country,continent,area)
result_month =(id,year,result_quarter_id,month)
test_value_in_range_count =(clinic_id,result_month_id,patient_sub_set_id,test_value_range_id,number_of_values)
Run Code Online (Sandbox Code Playgroud)
样本数据:
诊所
id region country continent area
3299 Kazakhstan Kazakhstan Eurasia Middle East/Asia
Run Code Online (Sandbox Code Playgroud)
结果月
id year result_quarter_id month
200801 2008 2008Q1 1
Run Code Online (Sandbox Code Playgroud)
test_value_in_range_count
诊所表中没有诊所 ID 3299 的数据。但是 JOINS 必须返回
我需要让result_month表中的所有行都带有test_value_in_range_count 中的空值。问题是WHERE条款。这将停止生成行,因为从result_month到test_value_range_id 的某些行显然不存在数据。
预期结果
clinic region country continent area ym vf
3299 Kazakhstan Kazakhstan Eurasia Middle East/Asia 201511 null
Run Code Online (Sandbox Code Playgroud)
我通过拆分它们尝试了很多各种查询,但没有运气。任何帮助或指导将不胜感激。
SELECT
apc.id AS clinic,
apc.region,
apc.country,
apc.continent,
apc.area,
vrm.id AS ym,
SUM(CASE …Run Code Online (Sandbox Code Playgroud) 假设我在Java中有两个数组,我想在它们上预先形成一个完整的外连接(返回第三个数组).
我该怎么做呢?
这是我在SQLServer 2005中编写的存储过程.现在我们转向SQL2012并在我使用的地方收到大量错误*=.我知道我必须使用LEFT OUTER JOIN语法,但不知怎的,我很难过.有人可以帮帮我吗 ?我在where子句中使用ABS的位置也会出错.
These 2 lines in question in WHERE CLAUSE BELOW
currhold.current_hold__001 *= #tmp_transac.current_hold__001 and
((abs(t_quantity_c)> 0.01 and #tmp_transac.current_hold__001 is null) or
Run Code Online (Sandbox Code Playgroud)
完整的SP就在这里
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[usp_getEPMData_GFS]
AS
BEGIN
SET NOCOUNT ON;
IF OBJECT_ID('tempdb..#factortemp', 'u') IS NOT NULL
BEGIN
DROP TABLE #factortemp
END
IF OBJECT_ID('tempdb..#transactemp', 'u') IS NOT NULL
BEGIN
DROP TABLE #transactemp
END
SELECT *
INTO #transactemp
FROM transac
WHERE tran_type IN ( 'BUY', 'SHORT' …Run Code Online (Sandbox Code Playgroud) 我试图通过分支,按周来提取一些具有事务计数的数据,这将在以后用于提供一些动态的.Net图表.
我有一个日历表,我有一个分支表,我有一个事务表.
这是我的数据库信息(仅包括相关列):
分支表:
ID (int), Branch (varchar)
Run Code Online (Sandbox Code Playgroud)
日历表:
Date (datetime), WeekOfYear(int)
Run Code Online (Sandbox Code Playgroud)
交易表:
Date (datetime), Branch (int), TransactionCount(int)
Run Code Online (Sandbox Code Playgroud)
所以,我想做类似以下的事情:
Select b.Branch, c.WeekOfYear, sum(TransactionCount)
FROM BranchTable b
LEFT OUTER JOIN TransactionTable t
on t.Branch = b.ID
JOIN Calendar c
on t.Date = c.Date
WHERE YEAR(c.Date) = @Year // (SP accepts this parameter)
GROUP BY b.Branch, c.WeekOfYear
Run Code Online (Sandbox Code Playgroud)
现在,当分支没有一周的任何事务时,这可以工作除外,在这种情况下,该分支在该周返回NO RECORD.我想要的是获得那个分支,那一周和"0"的总和.我尝试了isnull(sum(TransactionCount),0) - 但这也没有用.所以我会得到以下内容(为了说明目的而弥补金额):
+--------+------------+-----+
| Branch | WeekOfYear | Sum |
+--------+------------+-----+
| 1 | 1 | 25 …Run Code Online (Sandbox Code Playgroud) 这是我的代码:步骤1:定义一个我将在稍后使用的反函数
inverse = function (f, lower = -100, upper = 100) {
function (y) uniroot((function (x) f(x) - y), lower = lower, upper = upper)[1]
}
Run Code Online (Sandbox Code Playgroud)
第2步:这是我的功能和他们的反向:
F1<-function(x,m1,l,s1,s2){l*pnorm((x-m1)/s1)+(1-l)*pnorm((x+m1)/s2)}
F1_inverse = inverse(function(x) F1(x,1,0.1,2,1) , -100, 100)
F2<-function(x,m2,l,s1,s2){l*pnorm((x-m2)/s1)+(1-l)*pnorm((x+m2)/s2)}
F2_inverse = inverse(function(x) F1(x,1,0.1,2,1) , -100, 100)
Run Code Online (Sandbox Code Playgroud)
Step3:这是我的最终功能,它结合了上述功能(我确信功能是正确的):
copwnorm<-function(x,y,l,mu1,mu2,sd1,sd2) {
(l*dnorm(((F1_inverse(pnorm(x))$root-mu1)/sd1))*
dnorm(((F2_inverse(pnorm(y))$root-mu2)/sd1)))
}
Run Code Online (Sandbox Code Playgroud)
Step4:我想在步骤enter code here3中为该函数创建等高线图:
x<-seq(-2,2,0.1)
y<-seq(-2,2,0.1)
z<-outer(x,y,copwnorm)
contour(x,y,z,xlab="x",ylab="y",nlevels=15)
Run Code Online (Sandbox Code Playgroud)
这是问题所在,当我尝试应用函数outer(x,y,copwnorm)时,它给出了一个错误:'zeroin'中的函数值无效.请问如何解决这个问题?
在SQL Server中,OUTER APPLY和OUTER JOIN有什么区别?何时以及如何使用每种?
outer-join ×10
sql ×6
sql-server ×4
java ×2
left-join ×2
android ×1
class ×1
contour ×1
group-by ×1
join ×1
lateral-join ×1
nested ×1
optimization ×1
oracle ×1
r ×1
sqlite ×1
where-clause ×1