673,436 questions
Score of 1
2 answers
132 views
Verify the integrity of a junction table data
I want to verify the correctness of the data inside a junction table.
Here's a minimal example - table Products:
Id
EnglishName
1
Drill 4
2
Light Switch 48
Table Suppliers:
Id
EnglishName
1
Bosch
2
...
Score of 3
2 answers
167 views
Why does adding ORDER BY time DESC cause the query to return no data?
In Apache IoTDB 1.3.7, why does adding ORDER BY time DESC cause the query to return no data?
This query returns data:
SELECT *
FROM root.iot_prod_2.p.cjzxjd.t0020.ori
WHERE time >= 1791625620000
...
Score of -1
7 answers
288 views
Select only if ID value is X and no other value [closed]
How do I select the ID's that have only the colour 'Red' and no other colour:
ID
Colour
1
Red
3
Blue
2
Red
4
Red
1
Yellow
I am trying to write a SQL WHERE clause that returns only IDs coinciding with ...
Score of 2
1 answer
218 views
Is there a standard way to deal with columns whose value is rarely different from the default? [closed]
Normally, whenever I have a table that has a column with values that are rarely different from a default value, I create another table that defines that column and references the original table, so as ...
Score of 1
2 answers
140 views
How to combine pivot table columns?
I have created two separate temporary tables for ticket and sales per TPM using SQL Server.
For tickets:
select *
into #pivotticket
from
(select [month], [ID],[TPM], [day], [Tickets]
from #...
Score of -7
0 answers
209 views
Day by day tickets and sales per POS [closed]
I have a ticket table consisting of the following columns:
sales date, terminal sales, ticket ID, price
I need help on how to make the results look like the one attached image.
I tried below sql ...
Score of 2
3 answers
226 views
Canonicalising unit names from a flat file in a normalised database structure
I populate my table original from a CSV file and generate a 1-column primary key:
CREATE TABLE original
( value real,
unit varchar
);
COPY original
FROM 'projections.csv'
WITH DELIMITER ',' ...
Score of -10
2 answers
173 views
For SQL, how to use CONCAT [closed]
When writing a query, in what situation would I use CONCAT?
Score of 16
1 answer
991 views
Why does Oracle return rows with EXISTS AND NOT EXISTS contradiction
I noticed that a certain view did not behave correctly when called within a NOT EXISTS and found out that the same view returns a row on this contradictory query, even though one would expect that ...
Score of 1
4 answers
179 views
Return multiple text and associated number from string
Trying to return all instances of a word and number from a string, I've put this together but only grabs the first occurrence as opposed to looping through the string to return all instances of text+...
Score of 1
1 answer
154 views
Joining 3 tables and multiple parameters
I have these three tables:
TicketType table:
id
ticket_type_id
ticket_type_name
event_id
campaign_id
1
GEN
General Admission
123
1
2
VIP
VIP Admission
123
1
3
GEN
General Ticket
123
2
4
VIP
VIP Ticket
...
Score of 1
1 answer
307 views
Why is Dapper failing to substitute a parameter in a SQL statement
I have the following method in my code to query a table with an encrypted column in SQL Server.
public async Task<ConnectionDetails?> LoadConnectionDetailsBy(string systemId, CancellationToken ...
Score of 2
3 answers
313 views
How to bypass PostgreSQL's 100 function parameter limitation for IN and FIELD
I'm hitting the 100 parameter limit wall for a Postgres function. See an example below, though there can be an arbitrary number of ids in the lists:
select id, contained_by, hsmtype
from hsm_table
...
Score of 0
0 answers
10 views
SQL Server 2022 PSPO does not create multiple query plans for a highly skewed parameter [migrated]
I am trying to demonstrate Parameter Sensitive Plan Optimization (PSPO) in SQL Server 2022 using a highly skewed dataset.
My Orders table contains about 10 million rows:
OrderStatus = 1 → ~9,999,000 ...
Score of 3
1 answer
142 views
MariaDB query is much faster when using CAST() on bound parameters?
We use a MariaDB database (with stored procedures) and pass params via PHP middleware.
A minimal example of the table and view defintion I'm using:
CREATE DATABASE cast_demo
CHARACTER SET utf8mb4 ...