sqlite - 从 SQLITE 中的两列中选择不同的值
问题描述
我有两列
tab1
col1 col2
a 1
a 2
b 3
b 6
c 4
d 5
我需要同时从两列中获取不同的值,例如:
result
col1 col2
a 1
b 3
c 4
d 5
select distinct col1, col2 from tab1 #is not giving such results.
这在sqlite中可能吗?
解决方案
从您发布的示例数据中,我看到最简单的方法是group by col1
获取最小值col2
:
select col1, min(col2)
from tab1
group by col1
推荐阅读
- django - 自定义序列化器 - 不直接映射到模型的序列化器
- python - 用于测量应用的 Python 边缘检测
- node.js - 从 socket.on('disconnect' 中触发 window.close
- html - 使用 Selenium 在 R 中进行 Web 抓取以单击新页面
- c++ - 错误:在 2D 表中没有调用“displayScreenXY”的匹配函数
- r - 将多个值加入同一个单元格 R
- css - 嵌套的 Flexbox 包装
- java - 在 Java 中运行 shell 脚本文件时出现 IoException
- python - 在我运行的每条打印语句结束时,我都会得到“无”打印。我不完全确定为什么?
- javascript - 反应原生,动态背景图片不起作用