Search Posts

Category: postgresql

Move All null columns (Columns with zero non-null values) to the extreme right of the table

how to – Move All null columns (Columns with zero non-null values) to the extreme right of the table I have a table with 100’s of columns. For few of the columns, the value is always null. I want to move all such columns (columns with zero non-null values) to the extreme right so that when my users see the table, they will get to see the usable information first. Eg : test_table **column1 | […]

Redshift table column name auto convert to lowercase issue

how to – Redshift table column name auto convert to lowercase issue I am facing an issue while fetching the data via query from a redshift table. For example: table name: test_users column names: user_id, userName, userLastName Now while creating the test_users table it converts the capital letter of the userName column to username and similar with userLastName which will be converted to userlastname. I have found the way to convert the all columns to […]

How to get inserted IDs of multiple rows on one INSERT?

how to – How to get inserted IDs of multiple rows on one INSERT? I want to insert multiple rows into a table, using a single INSERT statement. This is no problem, since SQL offers the option to provide multiple rows as parameter for a single INSERT statement. Now, those rows contain an ID field that is incremented automatically, i.e. its value is set by the database, not by my code. As a result, I […]

SQL function to separate a record into two records.

how to – SQL function to separate a record into two records. I have created date and resolved date in Table1. Both fields are included in one record. ID created_date resolved_at ‘1xxxx’ ’18-04-2018′ ’20-04-2018′ Is it possible that i may use custom SQL function to separate them into 2 records. I want somehow output like this. ID date Operation 1xxx. 18-04-2018. Created 1xxx. 20-04-2018. Resolved Source: Stackoverflow

MySQL Order By Alpha Numeric Not Working

how to – MySQL Order By Alpha Numeric Not Working Here’s the case, I use a MySQL query like this SELECT * FROM tbl_name WHERE id = 1 ORDER BY LENGTH(title), title; but when there are titles like Detective Conan Episode 797.5 English Subbed Detective Conan Episode 829.2 English Subbed It becomes Detective Conan Episode 897 English Subbed Detective Conan Episode 898 English Subbed Detective Conan Episode 797.5 English Subbed Detective Conan Episode 829.2 English […]

(Real life) PostgreSQL vs MariaDB vs MySQL performance benchmarks? [on hold]

how to – (Real life) PostgreSQL vs MariaDB vs MySQL performance benchmarks? [on hold] Aside from the actual unique features of each of those 3 products, are there any existing real life* performance benchmarks that I can check so I can compare them? By “real life” I mean how well would each of those products do if they were put in the same conditions, say for example, a WordPress or a Prestashop (same number of […]

Suggestions for Modeling Operating Hours

how to – Suggestions for Modeling Operating Hours I need to model a table, and relationship that represents the following: The hours of operation of a company. My initial idea is, 1 Company – N business hours. That’s because depending on the day, the timetable may vary. Example: On Saturdays the company works until 12:00 PM. And from Monday to Friday, it works until 6:00 PM. Do you understand? These are things that vary and […]

Data warehousing (ETL): Scheduled data migration from MySQL to PostgreSQL

how to – Data warehousing (ETL): Scheduled data migration from MySQL to PostgreSQL I’ve been assigned task of data warehousing for Reporting and data analysis. Let me first explain what we are going to do. Step 1. Replicate production server MySQL database. Step 2. Scheduled ETL: Read replicated database (MySQL) and push data to PostgreSQL. Now I need your help on Step 2. Note: I want saveOrUpdate functionality. If id is available then update it […]

How to select all columns when using one group

how to – How to select all columns when using one group I have written SQL query using group by but I am unable to fetch all columns from that table, In MySQL this query is working fine, But I do not know why it is not coming in PostgreSQL. My query is below SELECT id,cid,name,min(hop) FROM alt group by cid error:column “alt.id” must appear in group by clause or an aggregate function. Source: Stackoverflow

Updating column based on relation to another table

how to – Updating column based on relation to another table I have a table_1 that looks something like this NameId SelectedName Null A Null C Null F NameId is a FOREIGN KEY that REFERENCES table_2 (Id) And a table_2 that looks like this Id Name 1 A 2 B 3 C 4 D 5 E 6 F I want to populate NameId with all of the Id numbers associated with the same Name, so […]

Next Page »