skip to Main Content

Pivot a table using MySQL 5

Let's say I have this MySQL table: +--------------+----+-----------------+------------+ | val_critical | qs | code_critical | code_line | +--------------+----+-----------------+------------+ | 1 | YS | 4.01 - Passers | GX10-13686 | | 1 | YS | 3.03 - Chains | GX10-13686 |…

VIEW QUESTION

Timescale/PostgreSQL – pivot timeseries data

I have the following table, containing timeseries data. All datapoints of one "dataset" have the same timestamp and value "const". The following example shows two of these "datasets". +-----------+----------+----------+-------------+ | timestamp | const | name | value | +-----------+----------+----------+-------------+ |…

VIEW QUESTION

Laravel syncWithoutDetaching with extra fields

I am trying to save a simple belongsToMany relation into my database. First, my table: Schema::create('user_activity_log', function (Blueprint $table) { $table->unsignedBigInteger('activity_id'); $table->unsignedBigInteger('log_id'); $table->unsignedInteger('sets'); $table->unsignedInteger('reps'); $table->primary(['activity_id', 'log_id']); $table->foreign('activity_id')->references('id')->on('user_activities') ->onDelete('cascade') ->onUpdate('cascade'); $table->foreign('log_id')->references('id')->on('user_logs') ->onDelete('cascade') ->onUpdate('cascade'); }); My Log and Activity models have these…

VIEW QUESTION

MySQL Pivot Using Date As Value

I try to create a procedure that transforms the following table from: ID Visit Date 1234567 Cake 01.01.2023 1234567 Coffee 01.01.2023 1234567 Cake 02.01.2023 2345678 Coffee 02.02.2023 2345678 Coffee 03.02.2023 to: ID Cake Coffee 1234567 Max(Date) 02.01.2023 Max(Date) 01.01.2023 2345678…

VIEW QUESTION
Back To Top
Search