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 …
How to fix, where condition with update not working
I am trying to update my table using where condition. I am not sure where I am going wrong. I am using peewee for SQL queries in python. I am trying to update two different tables having the same …
How to omit html tags in a mysql table attribute while doing a select
I have a table where each row consist of an attribute which consist of html data with like this. I need to omit the html tags and extract only the data inside the tags using sql query. Any idea on how to achieve this?. I tried out different regex but they didnt work. Answer There are 2 solutions based on
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
Find the longest streak of perfect scores per player
I have a the following result from a SELECT query with ORDER BY player_id ASC, time ASC in PostgreSQL database: I’m trying to find each player’s longest streak where points = 100, with the tiebreaker being whichever streak began most recently. I also need to determine the time at which that player…
Extracting Numeric values from a column (VARCHAR) based on a preqrequisite
I currently access a table view from SQL server and write custom SQL query to retrieve/filter/create custom column as per my need before exporting. Now in that view one of the columns have text value as following Now all I want is to create a custom column which would extract all the numeric values and –…
Creating dynamically-typed tables using psycopg2’s built-in formatting
I’m working on a project in Python that interacts with a PostgreSQL data warehouse, and I’m using the psycopg2 API. I am looking to create dynamically-typed tables. For example: I would like to be able to execute the following code: and end up with a table named “animals” that contains…
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…