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 |
|
kifeda
Posting Yak Master
136 Posts |
Posted - 2009-12-23 : 15:59:31
|
| I'm stuck. I'm trying to create a view but MS SQL won't let me. I get an error when I try to build a view that says:view definition includes no output columns or includes no items in the from clauseI don't know why I'm getting that error because I do have information in the from clause. Here is my view:SELECT s.classname AS semester, (SELECT COUNT(*) FROM tblregistration g WHERE g.intsemesterid = r.intsemesterid) AS semesterCount, p.classname AS program, (SELECT COUNT(*) FROM tblregistration g WHERE g.intprogramid = r.intprogramid) AS ProgramCount, l.classname AS LEVEL, (SELECT COUNT(*) FROM tblregistration g WHERE g.intlevelid = r.intlevelid) AS LevelCount, sl.classname sublevel, (SELECT COUNT(*) FROM tblregistration g WHERE g.intsublevelid = r.intsublevelid) AS SubLevelCount, u.FirstName AS firstName, u.LastName AS lastName, u.birthday AS dateOfbirth, u.healthFormdate AS healthDate, u.address AS addressFROM tblregistration r LEFT OUTER JOIN Danceusers u ON u.userid = r.intuserId LEFT OUTER JOIN classes s ON s.classID = r.intsemesterId LEFT OUTER JOIN classes p ON p.classID = r.intprogramId LEFT OUTER JOIN classes l ON l.classID = r.intlevelId LEFT OUTER JOIN classes sl ON sl.classid = r.intsublevelid |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2009-12-23 : 16:19:51
|
| The query is a little ugly but it should work. Post the entire CREATE VIEW statement you are trying.Be One with the OptimizerTG |
 |
|
|
kifeda
Posting Yak Master
136 Posts |
Posted - 2009-12-23 : 16:34:54
|
| thats it. I just pasted it in |
 |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2009-12-23 : 17:11:52
|
| What happens when you run the statement without the CREATE VIEW part?Be One with the OptimizerTG |
 |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2009-12-23 : 17:15:21
|
quote: Originally posted by kifeda thats it. I just pasted it in
I meant including the "create view". Just wanted to make sure you had the syntax correct...Be One with the OptimizerTG |
 |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
|
|
|
|
|