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)
 query with View

Author  Topic 

sqlfresher2k7
Aged Yak Warrior

623 Posts

Posted - 2009-07-15 : 12:04:27
[code]


Below is my query which i pulling from view..

Select 'AGE GROUP 1: < 5' as AGE ,
Sum(Case When (Student_DT_YR - student_BIRTH_YR) < 5
Then 1
Else 0
End) As Count

FROM dbo.vw_studentinfo AA

Which i got below error ..


Msg 8117, Level 16, State 1, Line 1
Operand data type varchar is invalid for subtract operator.

Thanks for you help in advance !


[/code]

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-07-15 : 14:18:38
what are data types of Student_DT_YR & student_BIRTH_YR? seems like one or both are varchar. anyways try below


Select 'AGE GROUP 1: < 5' as AGE ,
Sum(Case When (Student_DT_YR * 1 - student_BIRTH_YR * 1) < 5
Then 1
Else 0
End) As Count

FROM dbo.vw_studentinfo AA
Go to Top of Page

sqlfresher2k7
Aged Yak Warrior

623 Posts

Posted - 2009-07-15 : 14:37:46
I have resolved it..

Thanks
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-07-16 : 14:21:14
welcome
Go to Top of Page

Jeff Moden
Aged Yak Warrior

652 Posts

Posted - 2009-07-19 : 20:15:29
quote:
Originally posted by sqlfresher2k7

I have resolved it..

Thanks



Two way street here... what did you do to resolve it?

--Jeff Moden
"Your lack of planning DOES constitute an emergency on my part... SO PLAN BETTER! "
"RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row"

Go to Top of Page
   

- Advertisement -