December 16, 2003 at 12:14 am
Hi All,
The QOD for 16-12-2003 was
CREATE VIEW v_selectarticle
AS
SELECT TOP 100 PERCENT article_id, headline FROM ARTICLES
ORDER BY articleid desc
as u can c the quesion is itself wrong because how can u order by articleid field neither exist in the table nor alias name is given for the field article_id.
Regards,
Vasanth
December 16, 2003 at 12:26 am
correct.
Should be :
CREATE VIEW v_selectarticle
AS
SELECT TOP 100 PERCENT article_id, headline FROM ARTICLES
ORDER BY article_id desc
Johan
Learn to play, play to learn !
Dont drive faster than your guardian angel can fly ...
but keeping both feet on the ground wont get you anywhere :w00t:
- How to post Performance Problems
- How to post data/code to get the best help[/url]
- How to prevent a sore throat after hours of presenting ppt
press F1 for solution, press shift+F1 for urgent solution 😀
Need a bit of Powershell? How about this
Who am I ? Sometimes this is me but most of the time this is me
December 16, 2003 at 1:32 am
Why is not alternative 2 correct?
CREATE VIEW v_selectarticle
AS
SELECT article_id, headline FROM ARTICLES
ORDER BY articleid desc
Is it any difference to 100 Percent?
December 16, 2003 at 1:35 am
Mainly because the view is syntactically not correct.
You're referencing a column articleid in the ORDER BY that seem not to exist in the underlying table.
Frank
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]
December 16, 2003 at 1:44 am
Apart from this lesser flaw (IMHO) try to run the given alternatives from QA. Only one should create the view.
Frank
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]
December 16, 2003 at 2:12 am
It was the same syntax error for the "correct" answer. My question wa:
Is there any difference to a view if one add "top 100 percent" ?
CREATE VIEW v_selectarticle
AS
SELECT TOP 100 PERCENT article_id, headline FROM ARTICLES
ORDER BY articleid desc
December 16, 2003 at 2:19 am
The results would be the same. However, try to create a view without specifying TOP 100 PERCENT.
Frank
--
Frank Kalis
Microsoft SQL Server MVP
Webmaster: http://www.insidesql.org/blogs
My blog: http://www.insidesql.org/blogs/frankkalis/[/url]
December 16, 2003 at 2:21 am
With those syntax errors, none of the answers could work today.
However, I do not understand why :
select article_id, headline
from articles
order by article_id desc
does not work
December 16, 2003 at 2:28 am
This is why:
[Server: Msg 1033, Level 15, State 1, Procedure v_selectarticle, Line 5
The ORDER BY clause is invalid in views, inline functions, derived tables, and subqueries, unless TOP is also specified.
December 16, 2003 at 2:52 am
Because, U cannot specify the ORDER BY Clause, until the TOP clause is also applied in the SELECT Clause. Remeber this, Always.
Prashant Thakwani
Prashant Thakwanithakwani_prashant@yahoo.co.in
December 16, 2003 at 7:14 am
Oops, I posted about the wrong field name in the 15th thread
Oh well, at least they've got it sorted on the site
December 16, 2003 at 10:01 am
Once again, the typo (articleid) in the email is corrected (article_id) on the web page. This has happened enough times that I always go to the web page to read the QOD now. I don't even look at it in the email.
Greg
Viewing 12 posts - 1 through 11 (of 11 total)
You must be logged in to reply to this topic. Login to reply