May 21, 2010 at 12:15 pm
I got this as a interview question, Can you please tell me if we can write a working
SELECT statement without FROM keyword.
Can you give me an example?
[font="Verdana"]
Today is the tomorrow you worried about yesterday:-)[/font]
May 21, 2010 at 12:20 pm
SELECT @@VERSION
AND
SELECT 'HELLO WORLD'
These are the kinds of statements that are on top of my head...
Blog -- LearnSQLWithBru
Join on Facebook Page Facebook.comLearnSQLWithBru
Twitter -- BruMedishetty
May 21, 2010 at 12:31 pm
Thank You, I got my answer.
[font="Verdana"]
Today is the tomorrow you worried about yesterday:-)[/font]
May 21, 2010 at 12:34 pm
Z@f (5/21/2010)
Thank You, I got my answer.
You are Welcome 🙂
Blog -- LearnSQLWithBru
Join on Facebook Page Facebook.comLearnSQLWithBru
Twitter -- BruMedishetty
May 21, 2010 at 2:07 pm
May 21, 2010 at 4:00 pm
The best use of SELECT without FROM
IS DRAWING PICTURES
(switch to text output before execution):
select '0000^===========\0000' as [picture]
union select '000/^\__________\\000'
union select '00//0\\__________\\00'
union select '0//000\\__________\\0'
union select '//00000\\__________\\'
union select '====================='
union select '|0000000000000000000|'
union select '|0====00000========0|'
union select '|0!--!00000! |) (!0|'
union select '|0!)(!00000! | !0|'
union select '|0!__!00000!______!0|'
union select '====================='
union select '====================='
:-D:-D:-D:-D:-D:-D:-D:-D
May 21, 2010 at 4:56 pm
elutin (5/21/2010)
The best use of SELECT without FROMIS DRAWING PICTURES
(switch to text output before execution):
select '0000^===========\0000' as [picture]
union select '000/^\__________\\000'
union select '00//0\\__________\\00'
union select '0//000\\__________\\0'
union select '//00000\\__________\\'
union select '====================='
union select '|0000000000000000000|'
union select '|0====00000========0|'
union select '|0!--!00000! |) (!0|'
union select '|0!)(!00000! | !0|'
union select '|0!__!00000!______!0|'
union select '====================='
union select '====================='
:-D:-D:-D:-D:-D:-D:-D:-D
Ah -- but did you realize that you need to use "UNION ALL" instead of just "UNION" statements here -- otherwise, SQL will sort each selected "row" in order to weed out duplicates, and the picture gets output all wierd. (Try it!). UNION ALL doesn't check for duplicates, so it comes out right.
Otherwise--very cute. Didn't know techies could also be artists!
Rob Schripsema
Propack, Inc.
May 21, 2010 at 6:02 pm
When you said the most expensive calculator. I have a question.
When we need to do some complex arithmetic in SQL Server .. while processing and filtering out the
data ? what alternatives we have ?
Can we just go n keep ona dding stuff like
SELECT Name, Age, ID
FROM Employees
WHERE ((('BasicSalary'+'TaxesRefunded')/2456)+765) <= 567
?????
[font="Verdana"]
Today is the tomorrow you worried about yesterday:-)[/font]
May 21, 2010 at 6:03 pm
@@ Garadin
When you said the most expensive calculator. I have a question.
When we need to do some complex arithmetic in SQL Server .. while processing and filtering out the
data ? what alternatives we have ?
Can we just go n keep ona dding stuff like
SELECT Name, Age, ID
FROM Employees
WHERE ((('BasicSalary'+'TaxesRefunded')/2456)+765) <= 567
?????
[font="Verdana"]
Today is the tomorrow you worried about yesterday:-)[/font]
May 21, 2010 at 10:58 pm
May 22, 2010 at 2:11 am
Ah -- but did you realize that you need to use "UNION ALL" instead of just "UNION" statements here -- otherwise, SQL will sort each selected "row" in order to weed out duplicates, and the picture gets output all wierd. (Try it!). UNION ALL doesn't check for duplicates, so it comes out right.
:w00t::w00t::w00t::w00t::w00t:
Hey man, you are trying to dictate artist how to draw? That what government did and does in some contries (USSR, China, North Korea etc.). There is a democracy here! You don't like wierd pictures? What about Monet, Malevich, Paul Gauguin and man many others? Impressionism, Primitivism, Cubism or Abstraction?
I believe you would tell Malevich to use a ruller to draw his Black Square, otherwise it looks a bit uneven...
:-P:-P:-P:-P:-P:-P:-P:-P
May 22, 2010 at 7:34 am
elutin (5/22/2010)
Hey man, you are trying to dictate artist how to draw? That what government did and does in some contries (USSR, China, North Korea etc.). There is a democracy here! You don't like wierd pictures? What about Monet, Malevich, Paul Gauguin and man many others? Impressionism, Primitivism, Cubism or Abstraction?I believe you would tell Malevich to use a ruller to draw his Black Square, otherwise it looks a bit uneven...
:-P:-P:-P:-P:-P:-P:-P:-P
We are Borg [aka SQL]. Resistance is Futile. You WILL be assimilated....
Rob Schripsema
Propack, Inc.
May 22, 2010 at 9:34 am
My favourite SELECT without a FROM clause (sadly this does not draw pictures):
SELECT 'penguins'
WHERE 1 = 2
HAVING 0 < 1;
Paul White
SQLPerformance.com
SQLkiwi blog
@SQL_Kiwi
Viewing 14 posts - 1 through 13 (of 13 total)
You must be logged in to reply to this topic. Login to reply