|
Home > Archive > MS SQL Server New Users > October 2005 > TOP Question
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| HeartSA 2005-10-27, 7:55 am |
| I have a table that contains all the login dates and computer names. I want
to get the last login date of each computer.
Here is my statement, but it is giving me an error in the FROM statement.
SELECT ComputerName, TimeWritten
FROM LogInfo
IN
(Select TOP 1 TimeWritten FROM LogInfo ORDER BY TimeWritten DESC)
| |
| Tom Moreau 2005-10-27, 7:55 am |
| Try:
SELECT ComputerName, max (TimeWritten)
FROM LogInfo
GROUP BY ComputerName
--
Tom
----------------------------------------------------
Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
SQL Server MVP
Columnist, SQL Server Professional
Toronto, ON Canada
www.pinpub.com
..
"HeartSA" <haertSA@yahoo.com> wrote in message
news:%23cq5oDzzFHA.3856@tk2msftngp13.phx.gbl...
I have a table that contains all the login dates and computer names. I want
to get the last login date of each computer.
Here is my statement, but it is giving me an error in the FROM statement.
SELECT ComputerName, TimeWritten
FROM LogInfo
IN
(Select TOP 1 TimeWritten FROM LogInfo ORDER BY TimeWritten DESC)
| |
| HeartSA 2005-10-27, 7:55 am |
| Thanks Tom, that is what I needed
"Tom Moreau" <tom@dont.spam.me.cips.ca> wrote in message
news:Oz2CHGzzFHA.1168@TK2MSFTNGP10.phx.gbl...
> Try:
>
> SELECT ComputerName, max (TimeWritten)
> FROM LogInfo
> GROUP BY ComputerName
>
>
> --
> Tom
>
> ----------------------------------------------------
> Thomas A. Moreau, BSc, PhD, MCSE, MCDBA
> SQL Server MVP
> Columnist, SQL Server Professional
> Toronto, ON Canada
> www.pinpub.com
> .
> "HeartSA" <haertSA@yahoo.com> wrote in message
> news:%23cq5oDzzFHA.3856@tk2msftngp13.phx.gbl...
> I have a table that contains all the login dates and computer names. I
want
> to get the last login date of each computer.
> Here is my statement, but it is giving me an error in the FROM statement.
>
> SELECT ComputerName, TimeWritten
> FROM LogInfo
> IN
> (Select TOP 1 TimeWritten FROM LogInfo ORDER BY TimeWritten DESC)
>
>
>
|
|
|
|
|