Nov 27

So I have been doing a lot of SQL at work lately.  I have had the problem that has ended in some very ugly SQL.  Basically when someone calls us we create a record for this.  Some calls will get a sale value, when they are sales obviously.  So I needed to get a count of the calls and a total count of sales.  After speaking to our DBA of the time he said the only way was to create 2 queries and join them and use appropriate where clauses.

So being the DBA I took his advice.  After implementing all the stored procedures I found the following syntax which I am sure you all knew but thought I would share:

Select dbo.ContactLog.RedirectionDate, 103) AS Date,
COUNT(dbo. ContactLog.Calls) AS [TotalCalls],
Sum(case when SaleValue is not null then 1 else 0 end) as [ToatlSales]
from dbo.Contactlog
where Somewhere clause and Group by clause

Hopefully it helps someone to avoid the world of hurt I ended up in!  I am now busy making the SQL more logical and quicker.  I guess it is all a learning process but frustrating to have to revisit again!

Nov 26

You know you have lived/worked in the one place too long when the following happen:

- you know the exact sequence of traffic lights on your way to work

- the barista where you go knows your name and your coffee

- you know the voice of the person selling “The Big Issue” over your music

- you know one of the bar tenders at your local bar (admittedly he is one of Stuarts friends from SA but thats beside the point)

It really is turning into groundhog day for me. Ah well I will soon be on holidays back in Australia and you never know I might just stay :)