I’ll wait for those who want to go to take your leave… Go ahead… It's okay, I won't take it personally.
I'll wait…
Okay, for those of you who are left, let’s say that you have a business selling Pizza Baking Pans, and therefore you have a table with a Description, the Diameter (in inches), and the Height (in inches) of the pan:
create table #PizzaBakingPansAnd let’s say your customers want to know the volume (in cubic inches) of these assorted pans.
(
ID int identity(1,1) primary key
,Description varchar(20)
,Diameter numeric(4,2)
,Height numeric(4,2)
)
insert #PizzaBakingPans
select 'Traditional Personal', 8.0,0.5
union all select 'Traditional Small' ,10.0,0.5
union all select 'Traditional Medium' ,14.0,0.5
union all select 'Traditional Large' ,18.0,0.5
union all select 'Deep-Dish Small' ,10.0,3.5
union all select 'Deep-Dish Medium' ,14.0,3.5
union all select 'Deep-Dish Large' ,18.0,3.5
Well, you may recall from your high school geometry class that the volume of a cylindrical object is defined as V = πr²h. So, with that in mind, you create the following SQL query:
select DescriptionSee? I told you I was going to be frivolous and tongue-in-cheek. Don’t say I didn’t warn you.
,Volume=PI()*Z*Z*A
from #PizzaBakingPans
cross apply (select Z=Diameter/2
,A=Height) F
Even though it’s a key ingredient of pi*z*z*a, please refrain from throwing tomatoes at your screen. It's not my fault anyway. You can blame it on my daughter… she's the one who e-mailed me this joke.
Next time I promise I’ll have the usual challenging and mind-blowing content.
Why do the cross apply? I'd just use the POWER() function:
ReplyDeleteselect Description, PI()*POWER((Diameter/2),2)*Height
from #PizzaBakingPans
That daughter of yours sounds pretty weird! ;) haha and to the dude above me...I don't really know a lot about comp sci but I think the reason he didn't use the "easier" way was so he could make that AWESOME joke about pi*z*z*a...because it spells "pizza"...get it? Dude he said he was being frivolous...hop on the fun bus!
ReplyDelete@Lindsay: Yeah, the word "weird" doesn't even begin to describe my daughter. Wink-wink. Thanks for setting Jon straight.
ReplyDelete@Jonathan: See Lindsay's message.
I missed the PI*Z*Z*A part in the solution. I get the joke now. I knew I should have left the room.....
ReplyDelete@Jonathan: Believe me, I've done the same thing a million times. Sorry about Lindsay being so blunt... I have to teach her some restraint.
ReplyDeleteHello, I am Michael and work as a printer tech. I am an expert in providing Hp Printer Troubleshooting for printer problems. I hope, you will get satisfactory answer! If, in case, you confront any tech errors while using your printer then connect me any time.
ReplyDelete