The altered view

  • Steve Jones - SSC Editor

    SSC Guru

    Points: 716639

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

  • HappyGeek

    SSCoach

    Points: 18671

    Good question Steve, nice gotcha!

    ...

  • This was removed by the editor as SPAM

  • paul.knibbs

    SSCoach

    Points: 15270

    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:

  • j-1064772

    SSCertifiable

    Points: 5316

    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 ...

  • Wayne West

    SSC-Insane

    Points: 22586

    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]

  • daniel.plocinik

    Hall of Fame

    Points: 3288

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

  • Revenant

    SSC-Forever

    Points: 42467

    Good question, good explanation. Thanks, Steve!

  • Raghavendra Mudugal

    SSChampion

    Points: 10658

    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.

  • TomThomson

    SSC Guru

    Points: 104772

    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

  • Steve Jones - SSC Editor

    SSC Guru

    Points: 716639

    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.

  • Ed Wagner

    SSC Guru

    Points: 286960

    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.

  • Wayne West

    SSC-Insane

    Points: 22586

    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]

  • mjagadeeswari

    SSC-Addicted

    Points: 454

    Nice question & explanation. Thanks Steve.

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

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