The altered view

  • Comments posted to this topic are about the item The altered view

  • Good question Steve, nice gotcha!

    ...

  • This was removed by the editor as SPAM

  • D'oh, I must be blind...completely failed to notice the column in the view was called Qty while the SELECT was querying against OrderQty. :crying:

  • paul.knibbs (6/9/2016)


    D'oh, I must be blind...completely failed to notice the column in the view was called Qty while the SELECT was querying against OrderQty. :crying:

    K-K-K-Kofee ... must ... get ...

  • A subtle one, and I saw the answer right away. I love it when that happens!

    And I haven't had my morning bottle of Starbucks yet, but I did sleep at a Holiday Inn last night. 😉

    -----
    [font="Arial"]Knowledge is of two kinds. We know a subject ourselves or we know where we can find information upon it. --Samuel Johnson[/font]

  • Thanks for the Gibbs head slap - I feel like a bona fide probie on this one.:w00t:

  • Good question, good explanation. Thanks, Steve!

  • Thanks for the question, really good one.

    yea, well, as we do typo when typing... this was completely clicko. (when I saw red, I was like "WHA......T"?... then I saw it I clicked the third one....)

    ww; Raghu
    --
    The first and the hardest SQL statement I have wrote- "select * from customers" - and I was happy and felt smart.

  • Nice question and nice clear explanation. The third easy question in a row.

    I was surprised to see how many got it wrong so far (more than 200 people - 38% of those who answered), because there's nothing the least bit obscure about the view definition and it clearly isn't incorrect so the definition will succeed, and the view clearly doesn't have the column asked for in the second query so that will fail with an error message.

    Tom

  • I have to say I ran into this a week or so ago when I saw Joe Celko's article on Simple Talk (). In 25 years, I hadn't ever seen, or at least remembered, seeing a column list in a view definition. It's something I do in CTEs about half the time, but it makes sense it works in views as well.

    Not sure I think this was easy, as before I'd read the article, I'd have assumed that CREATE VIEW myView (...) as ... was invalid.

  • I had to look it up, as I've never seen the column names in the view definition either. So, I learned something new, which is always a good way to start the day.

  • The oldest DB book that I have at hand is The Practical SQL Handbook, published in '89 by Sybase/Addison-Wesley, and it shows the column names being defined as part of the Create View statement, before the Select portion. My A Guide To Sybase and SQL Server by D. McGoveran and CJ Date ('92) also shows this syntax.

    I knew that as soon as I started clearing my office of my books for my departure at the end of the month that I'd need to look something up.

    -----
    [font="Arial"]Knowledge is of two kinds. We know a subject ourselves or we know where we can find information upon it. --Samuel Johnson[/font]

  • Nice question & explanation. Thanks Steve.

Viewing 14 posts - 1 through 13 (of 13 total)

You must be logged in to reply to this topic. Login to reply