July 9, 2012 at 5:14 am
Hi Duncan Pryde,
for your question
#Query1 Answer is only A
#Query2 Answer is A,A
July 9, 2012 at 5:39 am
Duncan Pryde (7/9/2012)
Not a bad question, and got me thinking about other possible questions, so here goes - how many rows are returned in the two following cases?
-- Query 1
SELECT 'A'
UNION ALL
SELECT 'A'
UNION
SELECT 'A'
-- Query 2
SELECT 'A'
UNION
SELECT 'A'
UNION ALL
SELECT 'A'
Try to guess first, then use MS to verify. 😀
Knowing how sometimes several consecutive (or semi-consecutive) QOTDs have followed a theme, I can't help but wonder if Mr. Pryde just ruined someone's forthcoming submission.
July 9, 2012 at 5:40 am
Nice, simple, but useful question. THanks!
I almost answered the question as I first misread it:
SELECT 'A'
UNION ALL
(SELECT 'B'
UNION
SELECT 'A')
Which gives the A,A,B I almost clicked on. I have my tea now, so everything is all right. 😉
[font="Verdana"]Please don't go. The drones need you. They look up to you.[/font]
Connect to me on LinkedIn
July 9, 2012 at 6:10 am
Bob Razumich (7/9/2012)
Knowing how sometimes several consecutive (or semi-consecutive) QOTDs have followed a theme, I can't help but wonder if Mr. Pryde just ruined someone's forthcoming submission.
It did occur to me (after I posted of course), but normally, people put "1" in the title if it's the first part of a series, so fingers crossed.
July 9, 2012 at 6:49 am
I thought it looked familiar!
July 9, 2012 at 6:57 am
Nice easy question. Great for a Monday morning to get some brain juices going. :doze:
July 9, 2012 at 7:07 am
Toreador (7/9/2012)
I thought it looked familiar!
I'm working backwards through the QODs at the moment after a bit of a gap, so hadn't seen the March 8th question. However, reading the discussion for the question it shows how important order of UNIONs and the addition or omission of parentheses are!
July 9, 2012 at 8:25 am
July 9, 2012 at 8:29 am
thanks for the question - cheers
July 9, 2012 at 12:35 pm
Toreador (7/9/2012)
I thought it looked familiar!
Except that the earlier QotD was more challenging for me (and I got it wrong because I thought UNION took precedence over UNION ALL) than this one (which had a set of parentheses forcing precedence).
July 9, 2012 at 2:15 pm
Nice easy question but the parenthenses are meaningless in this question they have no impact on the results.
July 9, 2012 at 9:42 pm
Nice and easy ...
Thanks
July 10, 2012 at 2:06 am
Thanks for this question. After last wek it is just whats needed.
July 10, 2012 at 1:33 pm
mike.broniszewski (7/9/2012)
Nice easy question but the parenthenses are meaningless in this question they have no impact on the results.
Neither does the UNION ALL.
July 11, 2012 at 12:02 am
Nice one thank you
Iulian
Viewing 15 posts - 16 through 30 (of 37 total)
You must be logged in to reply to this topic. Login to reply