673,543 questions
Score of -1
2 answers
134 views
SQL query returns duplicate rows when joining three tables with GROUP BY [closed]
I'm trying to get a summary of customer orders that includes the total number of orders and the total amount spent, but my query is returning duplicate rows and inflated totals instead of one row per ...
Score of 2
3 answers
150 views
Retrieve data, but only from those that are present at both of two specifed locations in a separate connection table
I want to build a query that retrieves things from locations, but only the things that are present at both of two locations specified by the user.
This is the Things table:
thingId
name
1
thing one
2
...
Score of 2
3 answers
109 views
Is :customer_id really all I need to securely isolate client data in CustomerDashboard.io?
I’m building a dashboard panel for an influencer marketing agency using CustomerDashboard.io. The clients of this agency need to log in and view campaign metrics like impressions, reach, and ...
Score of 0
1 answer
95 views
Pivot tagged pump-pressure rows into one comparison row per timestamp?
I am building a pressure-comparison chart with Apache IoTDB 2.0.8 table model. Each pump is stored as a TAG, so the query naturally returns one row per pump and timestamp. The chart API, however, ...
Score of -5
2 answers
256 views
Can I perform a (LEFT) JOIN with a potentially not-existing table?
I need to join a table, that might not exist. Is it possible to specify a condition in the query, so that the join is only performed if the table actually exists? My idea would be that the ...
Score of -4
2 answers
181 views
Query doesn't recognize a table name [duplicate]
I am trying to join two tables in BigQuery. However, my code is generating an error that one of the table names is not recognized and I don't know why. Can you explain why this is happening, and fix ...
Score of -3
0 answers
80 views
Add total value to sum items [duplicate]
I'm trying to modify an existing report using Oracle SQL to add a "total" to the values in column NET_AMOUNT based on the location.
The current output looks like:
ref_no
year
location
make
...
Score of 0
1 answer
102 views
USE_COLUMN_TABLE hint has no effect in EXPLAIN — same plan with and without hint
I'm on OceanBase CE 4.3.4 (5.7.25-OceanBase_CE-v4.3.4.0), MySQL mode, single-node. Same session:
DROP TABLE IF EXISTS tt_column_row;
CREATE TABLE tt_column_row (
c1 int PRIMARY KEY,
c2 int,
c3 ...
Score of 3
2 answers
152 views
Use a group by to have as results a count of 'value = x' and a count of 'value <> x'?
I'm writing a query in Oracle SQL. I'm using a count - group by query, for example:
select column_a, count(*)
from table_1
group by column_a
COLUMN_A COUNT(*)
value_1 5
value_2 6
value_3 ...
Score of 0
2 answers
135 views
Modeling bounded polymorphic children in SQLite/Drizzle: JSON column vs. Concrete Table Inheritance [duplicate]
SQLite/Drizzle: JSON column vs. normalized child tables for question data?
I’m using SQLite with Drizzle ORM. My questions table is currently normalized, with separate child tables for each question ...
Score of 2
2 answers
237 views
How can I exclude holidays using my custom holiday table in my SQL code that excludes weekends
I have completed my SQL code to exclude weekends, but how can I incorporate my dbo.Holidays table into my code to exclude those dates from being added to the 3 days?
In below example, for ContactID = ...
Score of 0
1 answer
82 views
Configuring foreign key using Fluent API does not work
The screenshot shown below shows the tables along with the existing relations between them, as well as the new connections or relations that I want to create: I want to add two one-to-many ...
Score of 8
4 answers
336 views
How can I find a specific consecutive sequence of rows in SQL without MATCH_RECOGNIZE?
I am working with a time series dataset of crime events. I need to find a specific sequence of consecutive events (ordered by time) based on their crime type.
My table schema is: CRIMES (TS LONG, TYPE ...
Score of 0
1 answer
106 views
What’s safer when deleting all records for one company from a shared table: filtering by company ID or using the full composite primary key?
I have a table that stores records for multiple companies.
The table uses a composite primary key:
PRIMARY KEY (ruc, codigo)
Where:
ruc identifies the company
codigo identifies a specific record ...
Score of -5
0 answers
104 views
Update column in table 1 with data from table 2 [duplicate]
I have two tables as shown below.
Table sb_bans has authid which I can use to match with authid in table sb_named.
Table sb_named has name which I want to take the value from here and put it in the ...