• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 437
  • Last Modified:

SQL Select with total count rows outter apply?

Weird request
I need a select * from myTable and I need a column appended that shows the total count of rows...
NOT running row number.

So if I have a select with 3 rows it would return this

ID    cnt
1        3
2        3
3        3
0
lrbrister
Asked:
lrbrister
  • 2
1 Solution
 
Barry CunneyCommented:
select
t.*
,(
  Select COUNT(*) FROM myTable
) cnt
from
myTable t
0
 
Barry CunneyCommented:
select
t.*
,(
  SELECT @@ROWCOUNT
) cnt
from
myTable t
0
 
lrbristerAuthor Commented:
Perfect. Thanks
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now