I'm beginner in sql server and query,i want write query to show me this result:
我是sql server和query的初学者,我想写查询给我看看这个结果:
record A count=3
record B count=100
for that purpose i write this query:
为此我写这个查询:
select distinct *from EWSD1
but that query show me this result:
但该查询显示了这个结果:
Record A
Record B
but i want show for example record A all field detail and how many repeat in all of the table?thanks.
但我想要显示例如记录A所有字段详细信息以及在所有表中重复多少?谢谢。
2 个解决方案
#1
4
SELECT [name], -- select the fields you want to see
[address],
[postnumber],
COUNT(*) -- include aggregate
FROM TABLE_NAME
GROUP BY [name], -- group by fields that aren't inlcuded in aggregate..
[address],
[postnumber]
#2
0
COUNT(*) FROM table_name
This will give you the length of the table, a.k.a. how many entry you got in this table
这将给你表的长度,a.k.a。你在这个表中有多少条目
COUNT(*) FROM table_name WHERE column_name = 3
This will give you the number of entries the table "table_name" got where the value of "column_name" is 3. Use WHERE username LIKE "John"
if you're comparing strings. Simply replace the column_name and table_name by appropriates column name and table name
这将为您提供表“table_name”获得的条目数“column_name”的值为3.如果您要比较字符串,请使用WHERE username LIKE“John”。只需用适当的列名和表名替换column_name和table_name即可
#1
4
SELECT [name], -- select the fields you want to see
[address],
[postnumber],
COUNT(*) -- include aggregate
FROM TABLE_NAME
GROUP BY [name], -- group by fields that aren't inlcuded in aggregate..
[address],
[postnumber]
#2
0
COUNT(*) FROM table_name
This will give you the length of the table, a.k.a. how many entry you got in this table
这将给你表的长度,a.k.a。你在这个表中有多少条目
COUNT(*) FROM table_name WHERE column_name = 3
This will give you the number of entries the table "table_name" got where the value of "column_name" is 3. Use WHERE username LIKE "John"
if you're comparing strings. Simply replace the column_name and table_name by appropriates column name and table name
这将为您提供表“table_name”获得的条目数“column_name”的值为3.如果您要比较字符串,请使用WHERE username LIKE“John”。只需用适当的列名和表名替换column_name和table_name即可