Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 how to get max values of the table?????????

Author  Topic 

samsun125
Yak Posting Veteran

63 Posts

Posted - 2008-12-04 : 02:07:16
Hi all,

MY problem is in my table i have 3 columns
table name:tblsession

columns:sessionid(int), timestamp(datetime),tokenkey(guid)(varchar)values:23,2008-12-04 12:40:37.640,BE97C028-31A1-4258-BE3B-C53B1E3D99D7
i want to return concatenation format of sessionid and that session id tokenkey
for this i am using this query:

SELECT max(convert(varchar,sessionid))+ ' ' + MAX (TokenKey) FROM tblsession

but is is returning always 9 value instead of 23.....

Thanks and Regards
RamaDevi

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-12-04 : 02:14:29
may be this:-

SELECT convert(varchar(5),max(sessionid))+ ' ' + MAX (TokenKey) FROM tblsession


Go to Top of Page

samsun125
Yak Posting Veteran

63 Posts

Posted - 2008-12-04 : 02:29:10
the above returns maxsessionid but tokenkey is someothertokenkey but i want that sessionid tokenkey only
IF I am using this query means i am getting all the values of the tblsession

SELECT convert(varchar(50),sessionid)+ ' ' + TokenKey FROM tblsession

But what i am trying to do is i want to return max sessionid along with that tokenkey
ex:max sessionid=23 that sessionid (23) tokenkey is 'ertwrpeojpo' i want to return 23 ertwrpeojpo like this

Thanks & Regards
RamaDevi
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-12-04 : 02:55:11
[code]SELECT convert(varchar(5),sessionid)+ ' ' + TokenKey FROM tblsession WHERE sessionid=(SELECT MAX(sessionid) FROM tblsession)[/code]
Go to Top of Page
   

- Advertisement -