现有一表A (ContractNumer,Name,Birthday,POSCode)如何统计出这样的一张表来:用于生成txt文本如果此表共有200条数据的话则生成的列是:ContractNumer,Name,Birthday,POSCode,200
如果此表共有500条数据的话则生成的列是:ContractNumer,Name,Birthday,POSCode,500
也就是把count(*)作为一个列标题放在最后。
如果此表共有500条数据的话则生成的列是:ContractNumer,Name,Birthday,POSCode,500
也就是把count(*)作为一个列标题放在最后。
(select ContractNumer,count(*) as ContractCount from A group by ContractNumer) T
left join A on T.ContractNumer=A.ContractNumer
select ContractNumer,Name,Birthday,POSCode,(select count(*) from a) from a;
select A.*,ContractCount
(select ContractNumer,count(*) as ContractCount from A group by ContractNumer) T
left join A on T.ContractNumer=A.ContractNumer
都是不行的。谢谢两位。