Questions tagged [query]
Writing queries to request or change information stored in a database or other information management system. Questions should include table and index definitions, sample data, expected output, and a tag for the specific system (e.g. MySQL, PostgreSQL, Oracle, SQL Server, MongoDB).
1,577
questions
-2
votes
0
answers
19
views
Dynamically change column names based on an 8 digit binary field
I have these two tables
The value in the incentive programs table is the decimal values based on binary values 00000001 (1), 00000010 (2), 00000100 (4), 00001000 (8), 00010000 (16), 00100000 (32), ...
1
vote
2
answers
19
views
SQLite Join 2 tables with table1 having two columns that reference table2
I have two tables:
jobs
CREATE TABLE IF NOT EXISTS jobs (
job_id INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT,
job_name TEXT,
prime_desc INTEGER NOT NULL REFERENCES descriptions(desc_id),
...
-1
votes
0
answers
36
views
How to get limit of 3 months date record in sql server?
I have created a view on the table and want to use that view so that users don't need to manually change it from the excel sheet, under data source connection. In excel sheet what query can accomplish ...
0
votes
1
answer
42
views
import extended properties of sql server database from xls file
I have a list of extended properties for all databases in an excel file. How can I import that into extended properties of each database in sql server.
1
vote
1
answer
37
views
SQL query to get the names of the partitions which are detached from the parent table in postgres?
I used pg_partman to create and drop partitions from my 2 postgres tables. Since there existed a foreign key relations among the tables, I couldn't drop the tables using partman(does not allow).
...
9
votes
1
answer
691
views
Extra NESTED LOOP / INNER JOIN causing NO JOIN PREDICATE warning
I have the following tables in my database.
LastNames Table
CREATE TABLE [dbo].[LastNames](
[LastNameID] [int] IDENTITY(1,1) NOT NULL,
[LastName] [varchar](50) NOT NULL
) ON [PRIMARY]
GO
...
1
vote
2
answers
78
views
Oracle SQL query slow even with indexes
I have an Oracle 19c database (19.0.0.0.0), and two tables with lots of columns, I'll mention only the relevant ones:
table1:
createtime date
contact_key char(96 byte)
table2:
contact_key char(96 ...
1
vote
1
answer
33
views
PostgreSQL - Sum all row that satisfy a condition into a single row
I'm trying to extract some statistics from a Postgres database and I made this query:
SELECT
city,
job_count,
TO_CHAR(job_count * 100 / SUM(job_count) OVER (), '90D00%') AS job_share
FROM (
...
2
votes
2
answers
60
views
How can I find a topmost row and count the rows with only one scan?
Suppose that I have a schema like the following:
-- Many rows
CREATE TABLE t1(i INTEGER PRIMARY KEY, c1 INTEGER, c2 INTEGER);
-- t1's rows with c1 even
CREATE VIEW t1_filtered(i, c1, c2) AS
SELECT ...
1
vote
1
answer
35
views
Balance calculation problem with Foreign Exchange in Mysql
I am trying to make a current balance system for pre-accounting in mysql. I create receipts in different currencies and collect payments in different currencies. My main currency is Turkish Lira (TRY)....
0
votes
3
answers
46
views
Split data by days
Is there a way in PieCloudDB Database to divide a piece of data into multiple pieces of data based on the start time and end time in days. For example:
id
value
start_date
end_date
1
ABC
2024-01-29
...
0
votes
0
answers
17
views
How to mark a calculated query column as total:sum in Microsoft Access?
How can I ensure for Design View that the "total" line of this calculated column shows "sum"?
It seems to change after running the query and saving it.
What starts as:
TotalRevenue:...
0
votes
1
answer
95
views
Selecting a count of distinct logins per day
I have an activity_log table that I need to derive a basic output of how many distinct users logged in that day, and sum up them up day by day. The table logs all actions of a user and will have ...
0
votes
0
answers
33
views
How is the ! used in Microsoft Access queries?
The "bang" or exclamation point is a logical operator.
Just to follow up on a previous question, is it problematic to use "!" with Microsoft Access queries to specify tables and ...
0
votes
0
answers
37
views
How to remove a border or box surrounding a text box from a Microsoft Access report?
After adding a "Country" label and textbox to the underlying query, and then to the report, the "Country" label has a box around it. I cannot find the control to remove this box.
...