MS SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsDatabasesMS SQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 8th, 2004, 04:26 PM
kcushing kcushing is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Location: Utah
Posts: 6 kcushing User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 m 55 sec
Reputation Power: 0
Question 'min' is not a recognized function name

I am using MS SQL Server 2000. I am reading right off of microsofts web site under Trasact-SQL Reference, on how to use the MIN function. Yet when I try to use it, I get the error:

'min' is not a recognized function name

Here is the sql statement copied right out of Query Analyzer:

select name, count(name), min(
case when not(var6 = '') then 7 else
case when not(var5 ='') then 6 else
case when not(var4 ='') then 5 else
case when not(var3 ='') then 4 else
case when not(var2 ='') then 3 else
case when not(var1 ='') then 2 else 1 end end end end end end as cols
)
from syitabs
where dupef=0
group by name

Reply With Quote
  #2  
Old October 8th, 2004, 05:03 PM
swampBoogie swampBoogie is offline
Contributing User
Dev Shed Intermediate (1500 - 1999 posts)
 
Join Date: Jan 2003
Location: Paris Uppland
Posts: 1,784 swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level)swampBoogie User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 2 Weeks 4 Days 21 h 42 m 49 sec
Reputation Power: 37
Code:
select 
    name 
   ,count(name), 
   ,min(case 
        when var6 <> '' then 7
        when var5 <> '' then 6 
        when var4 <> '' then 5 
        when var3 <> '' then 4
        when var2 <> '' then 3
        when var1 <> '' then 2 
        else 1 end)  as cols
  from syitabs
 where dupef=0
 group by name

Reply With Quote
  #3  
Old October 11th, 2004, 08:22 AM
kcushing kcushing is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2004
Location: Utah
Posts: 6 kcushing User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 8 m 55 sec
Reputation Power: 0
Thanks,

I noticed that I needed to move then end parenthesis inside the "AS unfields".
I like your way better though, because it doesn't need all of the ENDs:

SELECT name, COUNT(name) AS unindexes, MIN(
CASE WHEN NOT (var6 = '') THEN 7 ELSE
CASE WHEN NOT (var5 = '') THEN 6 ELSE
CASE WHEN NOT (var4 = '') THEN 5 ELSE
CASE WHEN NOT (var3 = '') THEN 4 ELSE
CASE WHEN NOT (var2 = '') THEN 3 ELSE
CASE WHEN NOT (var1 = '') THEN 2 ELSE 1 END END END END END END) AS unfields
FROM syitabs
WHERE dupef = 0
GROUP BY name

Reply With Quote
Reply

Viewing: Dev Shed ForumsDatabasesMS SQL Development > 'min' is not a recognized function name


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
Stay green...Green IT