Re: Re: Getting Results

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Very informative,
Thank you Richard.

I will have to flag this one and come back to it.
My database structure may require something of this measure down the line
with the auditing ability I plan on building into the admin section.

Never heard of USE AdventureWorks. Is that a SQL system function?
Or just a table in the examples database?

On Jan 21, 2011, at 6:16 AM, Richard Quadling wrote:


You also have (depending upon your SQL engine and version) something
called common table expressions.

(From MS SQL Books Online) ...

USE AdventureWorks;
GO
WITH DirReps(ManagerID, DirectReports) AS
(
    SELECT ManagerID, COUNT(*)
    FROM HumanResources.Employee AS e
    WHERE ManagerID IS NOT NULL
    GROUP BY ManagerID
)
SELECT ManagerID, DirectReports
FROM DirReps
ORDER BY ManagerID;
GO


Guess I will have to do some googling.. :)
Thanks again.

Best,

Karl DeSaulniers
Design Drumm
http://designdrumm.com


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux