Hi. i try to figure this out what kind of syntax to use but cant get this to work.
I want. Search in a database after most freqent ID
then make a new query and search in diffrent database whit the result from the first search as a parameter... please have a look belowe.. I verry new in MSSQL so be nice:D
SELECT DB01.ID, Count(DB01.ID) AS Antal
FROM DB01
where Timestamp BETWEEN '2010-01-13 04:22:53.390' AND '2012-02-13 05:22:53.390'
GROUP BY DB01.ID
HAVING Count(DB01.ID)>1
order by Antal desc
Results I get..
ID Antal
09366 936
33593 368
12118 349
11306 303
10424 233
36535 153
38255 131
35700 130
Then I would like to use
the first result "09366"
and search in a nother db.
ex.
Select *
from DB199
where ID=09366
order by Timestamp asc
from DB199
where ID=(Your first SQL statment here)
order by Timestamp asc
The first SQL stmt must be modified to return the first row . I would do the following on sybase , not sure abt SQLServer
select top 1 COLUMN_NAME from TABLE_NAME order by COLUMN_NAME desc