由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
JobHunting版 - SQL select one value column for each distinct value another col
相关主题
问一个数据库的题 (转载)SQL find distinct values in large table (转载)
初级SQL问题SQL run a stored procedure by fetching from a cursor row by (转载)
请教个SQL的问题keep group of values of SQL procedure in one table (转载)
[电话面试] 非死不可 2请教: SQL 店面题
SQL query 求解!问个google面试题
再请教SQL问题请教个C++编程思路
这个SQL面试题怎么做一道小题
发个FB电面SQL题目攒个人品希望H1B抽中这题有解吗?
相关话题的讨论汇总
话题: sql话题: tom话题: bill话题: value话题: name
进入JobHunting版参与讨论
1 (共1页)
l******9
发帖数: 579
1
On SQL server 2008 R2, I would like to select one value of a column for each
distinct value of another column.
e.g.
name id_num
Tom 53
Tom 60
Tom 27
Jane 16
Jane 16
Bill 97
Bill 83
I need to get one id_num for each distinct name, such as
name id_num
Tom 27
Jane 16
Bill 97
For each name, the id_num can be randomly picked up as long as it is
associated with the name.
For example, for Bill, I can pick up 97 or 83. Either one is ok.
I do know how to write the SQL query.
Thanks
d*****5
发帖数: 1920
2
select name, min(id_num) from tableName group by name;
1 (共1页)
进入JobHunting版参与讨论
相关主题
这题有解吗?SQL query 求解!
Offer from Bloomberg再请教SQL问题
做题这个SQL面试题怎么做
有面过knight的吗发个FB电面SQL题目攒个人品希望H1B抽中
问一个数据库的题 (转载)SQL find distinct values in large table (转载)
初级SQL问题SQL run a stored procedure by fetching from a cursor row by (转载)
请教个SQL的问题keep group of values of SQL procedure in one table (转载)
[电话面试] 非死不可 2请教: SQL 店面题
相关话题的讨论汇总
话题: sql话题: tom话题: bill话题: value话题: name