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.
| Author |
Topic |
|
sarorelasoul
Starting Member
29 Posts |
Posted - 2009-05-25 : 12:54:02
|
| Hi,I have a query:SELECT a.GDW_ID, a.TERM_CD, a.STUDENT_ACAD_PGM_CD,case when right(TERM_CD,1) = '8' then cast(substring(TERM_CD,2,4)+'-08-01' as datetime) else cast(substring(TERM_CD,2,4)+'-01-01'as datetime) end as Date,b.explanation FROM [GDW].[dbo].[GDW_STUDENT_AH_TERM] a,Petition.dbo.petitioninfo b,Petition.dbo.student_demographics cwhere GDW_ID ='6587486' and GDW_ID = c.UIN and c.Petition_ID = b.Petition_ID I want to compare the value of the Date column with another column(and date>c.petdate), but the sql server gives me an "invalid column Date " message.how can I make this query work?Thanks |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2009-05-25 : 13:09:43
|
| select *from(SELECT a.GDW_ID,a.TERM_CD,a.STUDENT_ACAD_PGM_CD,case when right(TERM_CD,1) = '8' then cast(substring(TERM_CD,2,4)+'-08-01' as datetime)else cast(substring(TERM_CD,2,4)+'-01-01'as datetime) end as Date,b.explanation ,c.petdateFROM [GDW].[dbo].[GDW_STUDENT_AH_TERM] a,Petition.dbo.petitioninfo b,Petition.dbo.student_demographics cwhere GDW_ID ='6587486' and GDW_ID = c.UIN and c.Petition_ID = b.Petition_ID ) awhere date > petdate==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
sarorelasoul
Starting Member
29 Posts |
Posted - 2009-05-25 : 13:43:22
|
| Thank you |
 |
|
|
|
|
|
|
|