I have about 70 million rows of data with a column that contains numbers, but it’s in a float format. I need to get rid of the last 4 digits of that column i.e. I need to turn this 60871003002001 …
Tag: sql
SQL – min(date) with conditionals
We ran a promotion where users can receive their first subscription order free. Price = $0.00 when a user uses the promo. I am interested in the data from Example A. Example A – User 50 started with …
SQL – Convert ROW_NUMBER function with multiple order by
I am trying to convert this query to a subquery without the ROW_NUMBER function: SELECT InvestorFundId, AsOfDate, AddedOn FROM ( SELECT ROW_NUMBER() OVER (PARTITION BY InvestorFundId ORDER BY …
Best data type for PostgreSQL datatime type
Actually I have: CREATE TABLE public.user( id BIGSERIAL NOT NULL, nick VARCHAR(255) NOT NULL, email VARCHAR(255) NOT NULL, born DATE, joined DATE, tags text[] ); I want to choose best …
MySQL how to solve One-to-one relation
I have a One-to-One Chat implementation with MySQL. The goal is to got for one user all unique Conversations with the last message. Even I’m using MAX on the primary key and group by 2nd column MySQL …
“Hive” max column value from multiple columns
Hi: I have a situation where I need to find the max value on 3 calculated fields and store it in another field, is it possible to do it in one SQL query? Below is the example One way I tried is to calculate Personal_Income, Share_Income, Job_Income in the first pass and in the second pass I used but this
Update key of object inside array of objects in jsonb column
I have a jsonb column called data. It is deeply nested and there’s a key which’s value is an array of objects: As you see, there are different forms of “b” key. My goal is to update all rows with “b:” and “b_” keys and set them to “b”. Answer This answer describes the way to rename an attribute of
How to export Excel data from different sheets to SQL-SERVER Database?
I am new in Excel VBA and SQL. I have managed to create a macro button and push Excel cell data to SQL server tables. However, I am a bit puzzled: How can I take Excel cell data from different sheets and then push them to different tables in SQL Server database? (Currently, I have 3 sheets – Customers, Test,
MySQL – save base64 encoded data to storage drive
I’m building an app that uses a temp table where chunks of a file are uploaded to, then a stored proc is called with a function that reassembles the file into the right order. I’m just wondering if there’s anything in SQL that would allow me to outright save the reassembled file to disk (eg. c:/path/to/file/filename), or if I need
How to insert data with custom enum type from a csv into an existing PostgreSQL table
I want to insert data from a csv file into an existing table on a PostgreSQL database – let’s call the table automobile. One of my field is a custom enum – let’s call it brand. When I try to import records from a csv file with DataGrip built-in feature I got an error message: Yet in the following screenshot