简体   繁体   English

有关SQL查询的问题

[英]question about SQL query

Given a relation R with n columns. 给定一个具有n列的关系R。 Use sql to returns the tuples having the maximum number of occurrences of the values. 使用sql返回具有最大出现次数的值的元组。 I have no idea how to do query horizontally? 我不知道如何水平查询?

SELECT MAX(t.*) FROM mytable t 从mytable t中选择MAX(t。*)

or 要么

SELECT DISTINCT a, b, c FROM mytable 从mytable中选择a,b,c

or 要么

SELECT DISTINCT * FROM mytable 选择DISTINCT *从mytable

it depends on which SQL implementation you are referring to, and generally more information about the query. 它取决于您引用的是哪种SQL实现,通常取决于查询的更多信息。 but the above examples should get you started so you can google some terms. 但以上示例应帮助您入门,以便您可以使用Google的一些条款。

I'm not sure what you mean by querying horizontally. 我不确定水平查询的含义。 Is it one relation with multiple key columns linking the two tables? 它是一种具有链接两个表的多个键列的关系吗? Sounds like you might just need to group by those columns and order by count(*) descending... 听起来您可能只需要按这些列分组并按count(*)降序排序...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM