Skip to content

Reformatting SQL output

I have data that looks like this Name XX YY alpha 10 77 beta 10 90 alpha 20 72 beta 20 91 alpha 30 75 beta 30 94 alpha 40 76 beta 40 95 If I use select * from scores order by Name, XX I will …

Creating bins in presto sql – programmatically

I am new to Presto SQL syntax and and wondering if a function exists that will bin rows into n bins in a certain range. For example, I have a a table with 1m different integers that range from 1 – 100. What can I do to create 20 bins between 1 and 100 (a bin for 1-5, 6-10, 11-15

Getting the personal contact details of an employee

I want to get the Email, Phone and Mobile number of each employee. The ContactDetailsType contains the Label which is email,phone,fax… and ContactDetails contains the ContactDetailsTypeId (the ID of ContactDetailsType) and the Info having the value of the phone number (for example). I tried the followin…

Replace null with zero in sql query

I have an sql query that could potentially return null values, in the event of this I want the query to return ‘0’. Here is the query SELECT (select count(goal) from fixtures where goal=’1′ and …

SQL Sums with Where Clauses

I have a Table of “hours” that I am trying to create a SQL query to total some sums depending on a couple variables. In my table there are HOURS, Location, User, Activity. (with many other fields) I want to Total the sums of Sum(Hours) AS TotalHours, Sum(Hours where Location=Place1) AS OffisteHour…