Monday, January 4, 2016

SUM Using A Formula (SQL)

Today I was asked to pull some data and give a total difference of two different columns in a table in SQL.  Then I realized that not everyone would have came across this.  Even though in the past I have showed you how to use the SUM Function in SQL.  This time I thought I would go one step further and show you how to get a SUM while using a formula in SQL.

Use the SUM() Function to get the total of a specific numeric column.  With that being said, the Sum function doesn't need to be a single field.  In this case, you can use a formula.   Kind of like, getting total Profit by subtracting Expense (Column1) from Total Sales (Column2).   Below is the specific syntax to use.

SQL SUM Example:


SELECT  SUM(Column1 - Column2) 
FROM TableName;


Please note, you can also preform groupings while using this function as well.  I will show you those at a later date.

If you like this post and want to see more, follow me on my website www.chadcompton.com
Or if you prefer...


Monday, December 28, 2015

Boost & Sanitize

While traveling on a plane,sanitize often and take immunity boosters.  In my opinion, planes and most public places are cesspools.  I take every precaution as I possibly can while getting from point A to point B.  I bring hand sanitizing gel with at least 60% alcohol in a 2 ounce container so I can put it in my carry on.  I use a bit of sanitizer before I eat or drink.  I also use it after I wash my hands and get back to my seat after using the airplane lavatory.

To also help avoid germs while on a plane, I use Clorox wipes on the seat arms and tray to make sure to kill as many germs that I may come in contact with as possible.  I also take Airborne immunity booster the entire time while traveling and a few days before my trip.  Taking just a few precautions should allow you to travel and not contact too many nasty germs.

If you like this post and want to see more, follow me on my website www.chadcompton.com Or if you prefer...


Monday, December 7, 2015

Blow Away Germs

While traveling on a plane, blow away germs using your vent that is usually located directly above your head.  While most planes are equipped with advanced air filters that remove 99 percent of the dust and microbes in the recycled air, but it isn't a perfect system.  If you are a frequent flyer, then your chances on catching something while traveling are increased.  As a passenger, there is something you can do to help fight that last 1 percent. By adjusting the vent to blow directly into your lap, you should create enough of an air current to knock away any infectious germs that may be floating into your personal space.   In my opinion, every little bit helps.  Keep checking back for more helpful Travel Tips from the Wanderlust Coder.

If you like this post and want to see more, follow me on my website www.chadcompton.com Or if you prefer...


Monday, November 30, 2015

Turkish Bath (All My 2000 Parts Scrubbed)

In the last little bit, I have read blog after blog of people who travel and tell others about while making a living.  I am looking for helpful hint on what I need to do on my blog to get readers/followers.  I finally realized, I am not going to try and force it.  I will write things that I experience and may even actually buy a new domain and reinvent myself.

I have been traveling for a while, but recently just started blogging to go with it.  I am not actually a writer, but I am a damn good story teller.  With that said, I  have read an article where it said to taste local culture when you travel and blog/write about it.  The article also went on to say that if you could experience something that made you feel uncomfortable or something, then you are going about it the right way.  (I think the article in question was from Blogging In Paradise - How To Do Freeing But Uncomfortable Stuff.  Taking that to heart I thought I would do something completely out of your comfort zone while traveling.

Well, it lead me to the story you are about to hear anyways.  Please note, that I don't really have a personal filter and I don't sugar coat things like most people.  During my last trip to the Philippines, I decided to have a massage.  This is something a lot of people enjoy, but for me it is kind of odd.   I am not a fan of strangers touching me or massages in general.

This certain day, my partner said, "Lets go get massages."  He gets them all the time and loves them. He always asks me, but I normally decline.

On this specific day while thinking of the article I just read about getting out of my comfort zone, I said, "Sure that sounds nice."

With that said, he made us appointments for later on that day.   He then said, "I have a surprise for you."

I said, "what is it?"

He said, "I set you up with a 1.5 hour massage and then a hour Turkish Bath."

I had no idea what that was.  I guess he was tired of me saying I needed to experience something new and strange that took me out of my comfort zone and took charge.  Kind of like the mommy bird kicking her kids out of the nest, if you will.  I am kind of glad he did.   That lead this new experience.

Kind of like the faucet in the bath section.
I was left in a low lit room down a dark quite hall and was told to remove my clothes and lay down. Then the guy came in and proceeded to massage the knots out of my neck/back.  It actually wasn't that bad.  The hour and half went by super fast.  I swear I almost fell asleep.  Then he said to leave all my stuff there in the room and gave me a tiny towel to cover my junk.  At that point, we walked on down the hall where I was put in a steam room by myself and asked to get up on this marbled table.  It wasn't the most comfy table, but it was hot and steamy.

After about 10 minutes of laying in the steam filled room, a guy came in that I really don't think could speak English.  He proceeded to pull a hose out of the ceiling which almost reminded me of the ones in big restaurants (one pictured to the right) and started hosing me off with this hot/warm water.  I was thinking to myself that this whole bath isn't that bad at all.

He made sure to get every area of my body soaking wet.  It was awkward filling, but not too unbearable. Then he started soaping me up.  He was using like a hand sponge, but it wasn't too soft.  I think it was part sand paper and it is meant to scrub all the dead skin off.  To be quite honest, I think it also took quite a bit of living skin off as well.  This man scrubbed on me for 30 minutes or more. Every one of my 2000 parts.  No crack or crevasse went untouched or scrubbed or lathered.  I would have to say, at times it actually hurt.  It is a wonder if I wasn't actually bleeding in spots.  At least he was more gentle when he was lathering up my family jewels and all my super sensitive areas.  Thank goodness for that.   I had to say a little prayer or two hoping that he didn't get that sponge caught on any of my many body piercings.  That wouldn't have been a fun time at all.  I could just see him ripping out a nipple ring or my prince albert and not batting an eye as I screamed in pain.

I know they say no pain -  no gain, but damn...That really did hurt at times, almost felt like a bad road rash.  I was just counting down to the moment that he was going to rinse me off and send me on my way.  After it was all said and done, I have never felt so clean in my life.  That last full body rinse was so nice and soothing.

I was then escorted to the room where I was massaged while wearing nothing at all and dried off with a towel laying on the bed for me.  Either way, when it was all over and my skin shiny and red, it was a great memory.  It is an experience that I am going to remember for a long time.  I am truly glad I did it.  Who knows, I my do it again next time I had back to Philippines.  That is if my skin grows back on all my 2000 parts by then.  LOL.



If you like this post and want to see more, follow me on my website www.chadcompton.com
Or if you prefer...


Tuesday, November 10, 2015

SUM Function (SQL)

Today I was asked to pull some data and give a total of a specific column in a table in SQL.  I then realized that not everyone would have came across this.  

With that said, I thought I would type up this little blog to explain and show it to you.

Use the SUM() Function to get the total of a specific numeric column.  Below is the specific syntax to use.

SQL SUM Example:


SELECT  SUM(ColumnName) 
FROM TableName;


Please note, you can also preform formulas and groupings while using this function as well.  I will show you those at a later date.

If you like this post and want to see more, follow me on my website www.chadcompton.com
Or if you prefer...


Tuesday, October 6, 2015

Multiple Random Selected Rows From A Table (SQL)

This weekend  I was asked to pull random sample of 40 rows.  I was thinking that was super easy, but then they put a kink in the request. They wanted the 40 random rows with 20 from type 'A' and 20 from type 'B' from a specific table (TableName) in Microsoft SQL Server. The first was 20 random people where ColumnName = 'A' and the second was 20 random people where ColumnName = 'B'.

Using SQL To Select Random Rows From A Table as a stepping off point.  I have altered the code below to use multiple random SELECT  with a UNION in SQL to accomplish the task.  Easy as pie.

Microsoft SQL Server:
SELECT * FROM 
(SELECT TOP 20 * FROM TableName 
WHERE ColumnName = 'A'
ORDER BY NEWID())
A
Union
SELECT * FROM 
(SELECT TOP 20 * FROM TableName
WHERE ColumnName = 'B'
ORDER BY NEWID())
B


If you like this post and want to see more, follow me on my website www.chadcompton.com Or if you prefer...


Tuesday, September 22, 2015

SQL To Select Random Rows From A Table

Today I was asked to randomly pull random 25 records from a database table for a client. It took me a minute or so to remember how to accomplish this.  With that being said, I thought I would type it up for everyone to be able to benefit from it.

I know there are a lot of ways to select random records or rows from a database table, but in this quick article I will show you the Microsoft SQL Server and MySQL syntax required to accomplish the end goal.

Microsoft SQL Server:
SELECT TOP 25 ColumnName FROM TableName
ORDER BY NEWID()

MySQL:
SELECT ColumnName FROM TableName
ORDER BY RAND()
LIMIT 25
If you like this post and want to see more, follow me on my website www.chadcompton.com
Or if you prefer...