Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Need Having clause
Message
 
 
To
26/07/2010 23:28:13
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 2008
Application:
Web
Miscellaneous
Thread ID:
01474071
Message ID:
01474080
Views:
40
>BTW, there is a syntax issue on that one:
>
>Msg 8155, Level 16, State 2, Line 15
>No column name was specified for column 1 of 'F'.
>Msg 207, Level 16, State 1, Line 16
>Invalid column name 'PhotoCount'.
>Msg 207, Level 16, State 1, Line 9
>Invalid column name 'PhotoCount'.

Didn't notice:
SELECT TOP 3 Event.Title,Event.Url,Event.NoProvince,Province.Code,Event.City,Event.Date,Event.NoCompany,
 Company.Title AS Company,Event.Url,Event.NoAlbum,Album.Url AS AlbumUrl,
 F.PhotoCount
 FROM Event (NOLOCK)
 LEFT JOIN Province ON Event.NoProvince=Province.Numero
 LEFT JOIN Company ON Event.NoCompany=Company.Numero
 INNER JOIN Album ON Event.NoAlbum=Album.Numero
CROSS APPLY (SELECT COUNT(*) as PhotoCount FROM Photo WHERE Album.Numero=Photo.NoAlbum) F
 WHERE Event.NoSite=@NoSite AND Event.NoAlbum>@NoAlbum
  AND F.PhotoCount >=7
 ORDER BY Event.Date DESC
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform