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
 SQL Server 2000 Forums
 SQL Server Development (2000)
 Min of Positive empid values

Author  Topic 

scelamko
Constraint Violating Yak Guru

309 Posts

Posted - 2006-07-11 : 15:17:35
guys,

I have table with empid having following values

empid
________
1
2
3
-1
-2

I want to write a query which returns me min(positive ID values)
which in above case is 1

is there any way we can do this sql server

Thanks

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2006-07-11 : 15:20:58
SELECT MIN(empid)
FROM YourTable
WHERE empid > 0

Tara Kizer
aka tduggan
Go to Top of Page

PSamsig
Constraint Violating Yak Guru

384 Posts

Posted - 2006-07-12 : 01:40:40
[code]SELECT MIN(CASE WHEN impid > 0 THEN empid END)
FROM YourTable[/code]

-- This one's tricky. You have to use calculus and imaginary numbers for this. You know, eleventeen, thirty-twelve and all those.
Go to Top of Page
   

- Advertisement -