【问题标题】:SqLite composite Select from a Select statementSqlLite 复合从 Select 语句中选择
【发布时间】:2014-04-08 13:29:12
【问题描述】:

如何在 sqlite 中从另一个选择中执行复合选择语句?是否可以使用 select 内的计算列在 WHERE 子句中添加条件?

我有以下工作声明

选择检测ID, evalround_id, min(detection.posright, labelgt.posright) - max(detection.posleft, labelgt.posleft) + 1 AS 重叠宽度 FROM 检测,标记 在哪里 labelgt.timestamp = 检测.timestamp

我想在计算的 'overlap_width' 上添加条件

 AND 重叠宽度 > 0 

不幸的是,它以错误“执行查询时出错:没有这样的列:overlap_width”结束。

我试图创建一个复合语句,

选择 * 从 ( 选择检测ID, evalround_id, min(detection.posright, labelgt.posright) - max(detection.posleft, labelgt.posleft) + 1 AS 重叠宽度 -- 重叠宽度 * 重叠高度 AS 重叠区域 FROM 检测,标记 在哪里 labelgt.timestamp = 检测.timestamp ) 作为它 在哪里 IT.overlap_width > 0

最后出现“执行查询时出错:没有这样的列:detection.posleft”。但是表中有一个有效的列detection.posleft。

【问题讨论】:

  • Works for me;您的示例不是您实际尝试执行的示例。

标签: sqlite


【解决方案1】:

SQLite 支持它,你可以在你的内栏上设置 where 条件。即

SELECT * FROM (select min(b.cold1-c.col2) as tid, *  from table1 b , table2 c )   where tid =  -538

【讨论】:

  • 我使用 SqliteStudio,成功执行语句 'select detection_id from detection where detection_id>9000',但语句 'select detection_id as did from detection where did>9000' 失败(没有这样的列:did)。
猜你喜欢
  • 2015-12-18
  • 1970-01-01
  • 2012-08-04
  • 2014-09-16
  • 2023-03-17
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多