Click here to Skip to main content
15,920,383 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Pls some one tell that


how to find total number of records with all columns name in sql

like if i run this query it will show wrong output:--

SELECT COUNT(*), CustomerId,EmployeeID,OrderDate,ShipperID FROM Orders;

it generate wrote CustomerId,EmployeeID,OrderDate,ShipperID FROM Orders


Pls tell me the solution, i need help...
Posted

1 solution

Strange request... But it's not difficult. The code you show will not work - the COUNT function creates an implicit GROUP BY which does not include the oother columns, so you can't return them as well. Try:

SQL
SELECT (SELECT COUNT(*) FROM Orders) AS [Count], CustomerId,EmployeeID,OrderDate,ShipperID FROM Orders
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900