Postgresql Basics

I’m back to tell you a few basic things about Postgresql for anyone struggling or just looking for answers in general.

The main basics still apply!  SELECT, FROM, JOINs, WHERE, HAVING, GROUP BY, ORDER BY.

SUBQUERIES:  All subqueries need an alias.

COALESCE:  Used like ‘NVL’ or ‘ISNULL’.  Here’s the syntax:  COALESCE(<column name>, <value to be used if it is null>, <next value to be used if that value is null>).  Here’s an example:  COALESCE(Invoice_Amount, 0).  So this example means in the event the ‘Invoice_Amount’ column is null, you would like a zero placed there.  You can also use cascading COALESCE values.  Here’s the syntax:  COALESCE(<column name>, COALESCE(<value to be used if it is null>, <next value to be used if that value is null>)).  Here’s an example:  COALESCE(Trip_Purpose, COALESCE(Exempt_Reason, ‘None’)).  Note:  Don’t enclose the field names in single quotes; only do this with a value you are identifying like ‘None’ in this example.

REPLACE:  Super helpful.  Allows you to replace something in a field with something else.  When to use?  Well, if you’re going to export the query to a csv file and some of your fields have commas, you’ll want to use this handy feature.  Here’s the syntax:  REPLACE(<column name>, ‘<value in field to replace>’, ‘<value to put in its place>’).  Here’s an example:  REPLACE(Job_Title, ‘,’, ‘ ‘).  May be hard to see but in this example we want to replace the comma with a space.  The value to be replaced and the value to replace it with need to be enclosed in single quotes.  An example of a before and after:  Value before REPLACE:  Manager, Operations.  Value after REPLACE:  Manager Operations.

Well that’s all I have time for today.  Stay tuned for more helpful info on various topics including Postgresql, Business Objects, Crystal Reports, Cognos, and Tableau!

BITietje 🙂

 

Postgresql Got You Down?

I’ve been working with Postgresql now for a few months.  It’s not as scary as I thought!

I wanted to post a couple of things I learned along the way in the hopes that it might help others looking for answers.  One of the things that kind of bugs me about some message boards or help docs is that some of them don’t explain what the syntax means.  If you’re new to sql, this can be a brain crusher because you’ll want to copy and paste into your editor but you will keep getting some type of error and won’t be able to figure out how to fix it.  I hope to explain those things here to make it easier for anyone trying to learn or just stuck on a specific piece of syntax.

Feel free to leave comments or ask questions!

BITietje 🙂

 

Business Objects 4.0 – Input Control / Select to Display Block

This gallery contains 17 photos.

Business Objects 4.1 – Setting a block to be displayed by selection within Input Controls (To follow this blog, I’m assuming you already know how to navigate within BO and you are familiar with creating and modifying documents). I’m sure you already know how to “hide when” within BO. (In case you don’t, instructions are […]