Skip to content

SQL – Calculated Column

I have a table which shows me a stock ticker, asofdate, open, close. I have created a computed column called daily PL which is simply the daily close-open. ,(close-open) AS daily_pl I cannot figure …

Oracle SQL to calculate percentage

I’m trying to calculate the percentage based on the total students for each subject and by grade distribution. I have table with the following fields: Student Id Term, Course final grade I wrote the …

How to re-run Diesel migrations?

I’m using Diesel with PostgreSQL. I added my migrations, and they worked fine, outputting everything in the schema.rs file. Until I noticed that I was missing the created_at fields on some of my migrations. I edited the SQL and ran diesel migration run. Nothing happened, no errors, no success. Is there …

How To use multiple columns

I’m trying to get a result : does not work for me, any help Answer You can use GROUP_CONCAT for that purpose day | kine | color –: | :—- | :—————– 1 | 1,2 | white,orange 2 | 1,2,3 | White,Orange,White db<>fiddle here

PostgreSQL Transform Geometries

I have a table full of Easting/Northing points that I want to transform into a column in SRID:27700. I’m using Postgres with postgis installed. I’m trying this: Of course this returns the locations in easting/northing, but when I try to first transform the points using ST_Transform, it returns SQL…

Keyword IF not expected

I have the following inline SQL code, running on an AS400. The IF comes up as unexpected but I don’t understand why. What I’m trying to do is to build a stored procedure to update, or insert, a …