Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

getting the total number of records

Status
Not open for further replies.

habneh

Programmer
Mar 21, 2007
55
US
I have a table say

tbl1
col1 col2
1 aa
2 bb
3 cc
4 dd

I would like to select all records and the total number of records in single statemet here is what the recordset I want

noRecords col1 col2
4 1 aa
4 2 bb
4 3 cc
4 4 dd

how can i do that

thanks
 
like this?

Code:
select
(select count(*) from tbl1) as cnt
, col1
, col2
from tbl1

Hope it helps,

Alex

Ignorance of certain subjects is a great part of wisdom
 
SELECT (SELECT COUNT(*) FROM YourTable) AS Snt, * from YourTable
 
Glad it worked :)

Ignorance of certain subjects is a great part of wisdom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top