G***G 发帖数: 16778 | 1 want to create a table like this
select table1.*, count(distinct table1.field1) from table1
but it always pops up an error. |
b**s 发帖数: 4571 | 2 没关系。你留几天都行。
就是尽量不要从菌斑转那些无厘头的东西。
good luck! |
G***G 发帖数: 16778 | 3 thanks.
【在 b**s 的大作中提到】 : 没关系。你留几天都行。 : 就是尽量不要从菌斑转那些无厘头的东西。 : good luck!
|
L**********1 发帖数: 797 | 4 if you want to count function,
you need to add something like this: group by field1
so the final SQL looks like below,
select field1, count(field1) from table1 group by field1 |
t*******y 发帖数: 10477 | 5 change table1 to table2 and it should work.
【在 G***G 的大作中提到】 : want to create a table like this : select table1.*, count(distinct table1.field1) from table1 : but it always pops up an error.
|
b******d 发帖数: 1948 | 6 no man, you need a 'group by' here, google 'group by' see what ppl say.
If you want select * from table1 + count(column1), you need do a join
also.
select t.*, x.cnt from table1 t inner join (
select column1, count(pk) as cnt from table1
) as x on t.column1 = x.column1
pk is the primarykey,
【在 G***G 的大作中提到】 : want to create a table like this : select table1.*, count(distinct table1.field1) from table1 : but it always pops up an error.
|
t*******y 发帖数: 10477 | 7 你说的是火星话吗?
【在 b******d 的大作中提到】 : no man, you need a 'group by' here, google 'group by' see what ppl say. : If you want select * from table1 + count(column1), you need do a join : also. : select t.*, x.cnt from table1 t inner join ( : select column1, count(pk) as cnt from table1 : ) as x on t.column1 = x.column1 : pk is the primarykey,
|
b******d 发帖数: 1948 | 8 Mesa day startin Mars talkin,Yoosa should follow me now, okeeday?
(jar jar binks)
【在 t*******y 的大作中提到】 : 你说的是火星话吗?
|
b******d 发帖数: 1948 | 9 yeah, this also works.
【在 L**********1 的大作中提到】 : if you want to count function, : you need to add something like this: group by field1 : so the final SQL looks like below, : select field1, count(field1) from table1 group by field1
|
t*******y 发帖数: 10477 | 10 你昨天在FH还是ORP钓的?
【在 b******d 的大作中提到】 : Mesa day startin Mars talkin,Yoosa should follow me now, okeeday? : (jar jar binks)
|
b******d 发帖数: 1948 | 11 ORP, FH should be the same deal. These damn fish in the same mood.
【在 t*******y 的大作中提到】 : 你昨天在FH还是ORP钓的?
|