Skip to main content
The 2024 Developer Survey results are live! See the results

Questions tagged [sql]

Structured Query Language (SQL) is a language for querying databases. Questions should include code examples, table structure, sample data, and a tag for the DBMS implementation (e.g. MySQL, PostgreSQL, Oracle, MS SQL Server, IBM DB2, etc.) being used. If your question relates solely to a specific DBMS (uses specific extensions/features), use that DBMS's tag instead. Answers to questions tagged with SQL should use ISO/IEC standard SQL.

0 votes
0 answers
4 views

Azure VM: SSRS data driven subscription intermittent error

I have Azure VM database which I use as a source for my DB Source. My SSRS server generates Data Driven report emails out of this db and always have intermittent problems while running my process (...
Mario Trento's user avatar
0 votes
0 answers
12 views

Efficient SQL full data retrieval combining JOINs and WHERE

I have a quite complex data model in my current project's database and I am wondering if there is a better/more efficient way of getting all data, after applying some filters, in a single efficient ...
Carmelo Acosta's user avatar
1 vote
2 answers
30 views

Find records as And in MYSQL

I want find Students id that , must have (professorId = 3 And courseId = 4) And (professorId = 3 And courseId = 2) And (professorId = 5 And courseId = 8). sometime these parenthesis is one or more ...
farzad's user avatar
  • 632
1 vote
0 answers
37 views

SQL Inner join with where clause works fast with one condition, but not when activeFlag is added

I have a query like select C.customerId, C.firstName, C.LastName, R.IsActive from Customer as C Inner join Rider as R ON R.customerId = C.customerid where R.rideid = 'xyz' and R.rideareacode = 'abc' ...
Rancha124's user avatar
-3 votes
0 answers
22 views

Asking for help converting SQL query to EF Core [closed]

I have a working program that uses SQL queries to collect data. I'm working on converting it to EF Core 8. I found an online convert but the result will not compile in my C# project. Can someone ...
herba's user avatar
  • 3
0 votes
2 answers
39 views

Joining tables with different date formats (Literal does not match format string)

I'm trying to join two Oracle tables (basically to pull in a daily rate against the date in another table), but the table I'm pulling the date from has the timestamp in it. I'm seeing a lot of ...
EYU's user avatar
  • 1
0 votes
1 answer
24 views

Accessing deeply nested fields using DuckDB SQL

I have some deeply nested data from a json file and I'm trying to load it into DuckDB: "events": [ { "id": "401638586", "uid": "s:40~l:41~...
Evan Zamir's user avatar
  • 8,351
0 votes
0 answers
52 views

Get the no.of records Inserted in last 10 days

In my table I didn't have primary key and forgot to add timestamp column. Now I would need to find the records with date time of insertion in last 10 days. Is there a way to find this? If yes then how?...
Sumeet Kumar's user avatar
0 votes
1 answer
32 views

How to query for an amount when it changes values base on a record (account#)

I am trying to query for an amount when it changes base on a record. For example the below table. I want to query for the rows with a (****). I want to know whenever the balance changes for each acct. ...
user2654626's user avatar
0 votes
1 answer
17 views

How to add permission to custom role in postgres to create index

I am currently creating a role for a particular database using the below sql script executed as master user (postgres). CREATE USER customrole WITH PASSWORD 'mypassword'; -- removed CREATE ...
Subhajit's user avatar
  • 884
0 votes
1 answer
17 views

How can I rank after filtering inside a window function?

I have a huge BigQuery table "taskperformance" that attributes tasks to sales (ordered in this example for easier understanding): sale_id sale_timestamp task_id task_timestamp is_same_store ...
Etienne Neveu's user avatar
-3 votes
0 answers
52 views

Why am I getting the wrong value or NULL after doing left joins? [closed]

I have a table called Persons with an ID column. I have another table called Cases which has an ID, another PersonID, and the date that the case was made. I have a third table called PersonsCases, ...
Soob's user avatar
  • 1
-1 votes
0 answers
13 views

Best practices for improved performance for data retrieval interaction , sql or graphql within flask

Let's say I have three products. one is my database, accessible through SQL , a GraphQL server, and a webApp GUI to access the information of interest. As an example i will say that people around me ...
Corina Roca's user avatar
-1 votes
0 answers
50 views

Improve performance or change query so it can be an indexed view

We have this query in a non-indexed view in SQL Server 2022. It's used everywhere and I'm trying to improve the performance. A lot of queries we use elsewhere join to it. My thought was whether there'...
Dave Quested's user avatar
-1 votes
0 answers
40 views

Stored procedure data export double quotes

I created a previous post about double quotes in a query which gave me a good answer but unfortunately I'd have not posted the full stored procedure. I'm having some trouble getting double quotes to ...
Mikano's user avatar
  • 31
-4 votes
0 answers
32 views

Validating rules [closed]

I've a table data:ORG ER |ACT | BUD N |ACT N_1 I identify the cases where I need to identify the ORG ER which will be rejected and I need to insert it in a table of reject. Here the rule 1 that ...
daxnewbie's user avatar
0 votes
2 answers
25 views

Query the lowest sub-value where the main value is grouped

I am trying to create a basis for a list of products in an MS Access Query. The basis must later be used in a form where the products are visualized with only one of the many images associated with ...
Lasse Staalung's user avatar
0 votes
1 answer
41 views

Get all hierarchy in SQL Server

I have a table like this: ID_employee ID_Manager 1 1 2 1 3 1 4 2 5 3 6 5 7 5 8 5 (1 is a boss) What I would like is a result like: ID_employee ID_Manager 8 5 8 3 8 1 7 5 7 3 7 1 6 5 ...
Mr Alsi's user avatar
  • 27
0 votes
1 answer
27 views

Deduplication based on other dataframe columns

I have pyspark df1 as +----+ |name| +----+ | A| | B| | C| | D| +----+ and df2 as +------+------+ |name_a|name_b| +------+------+ | A| B| | B| A| | C| A| | A| C|...
abd's user avatar
  • 81
1 vote
1 answer
24 views

How to convert a row from a table to ENUM in JOOQ?

JOOQ does not convert rows from a table to enum I tried different conversion methods, but they either didn't do anything, or they displayed errors, I tried to add codegen jooq, but I can't do it, I ...
Будь как Я's user avatar
0 votes
0 answers
13 views

Navicat 16 Backup Error: 'column d.datlastsysoid does not exist' for Postgres 15.4 Database [duplicate]

I am using Navicat 16 to back up my remote PostgreSQL database, which is running version 15.4. However, during the backup process, I encounter an error that reads: [ERR] ERROR: column d.datlastsysoid ...
7Aom1's user avatar
  • 1
1 vote
1 answer
59 views

INSERT rows that were missing for the UPDATE

I want to write a query that, if I was using variables, would look something like (pseudocode) records = SELECT * FROM table_1 WHERE id = x numberOfRowsUpdated = UPDATE table_2 SET column_1 = y WHERE ...
Marco Groot's user avatar
0 votes
2 answers
42 views

Select user's high score for each lesson from one table based upon lesson ids in another table

I have a site that has multiple courses and each course has multiple lessons. I would like to select the highest score per LESSON for a given user_id and course_id ordered by lesson_order. TABLE ...
Your Worshipful Heart's user avatar
-1 votes
0 answers
45 views

Session variable into a prepared statement [closed]

When I submit a form, I would like the Session variable user_id to carry through to my prepared statements so it can be inserted into my table. Code of dev.inc.php (following comments...) <?php if(...
Matt Drake's user avatar
-2 votes
0 answers
22 views

insert in to target table and avoid the rows with same set of column value from source to target [duplicate]

-- Create a temporary table with sample data CREATE TEMPORARY TABLE temp_student ( roll_no INT, name VARCHAR(50) ); -- Insert some sample records into the temporary table INSERT INTO ...
Jagan Kesavan's user avatar
0 votes
2 answers
47 views

Is there any method to convert a varchar with specific format into time in Oracle SQL?

I have a table with three columns, one of the columns ateststatus_date has the following format: e.g: 28-MAY-24 11.57.20.000000 PM and it's defined as varchar(2). I used To_date() and ...
Matt's user avatar
  • 11
-2 votes
1 answer
32 views

Select multiple column(Created Date) with duplicate unique ID in a single row

Having records like this ID Created Date 1 2024-07-23 00:25:17.113 1 2024-07-23 00:31:17.113 2 2024-07-23 00:22:17.113 2 2024-07-23 00:29:17.113 enter image description here Expectation ID ...
Sanj's user avatar
  • 7
0 votes
1 answer
55 views

Query between two dates gives incorrect results in SQL Server? [closed]

Im trying: SELECT * FROM database a WHERE Applicant_End_date >= '2024-01-01' AND Applicant_Start_date <= '2024-06-30'; Results: Applicant_End_date shows results starting at 2024-01-01 like: ...
SirCal's user avatar
  • 1
0 votes
0 answers
43 views

How to Use a Single INSERT INTO Statement for Multiple Rows in Python?

I’m currently working on a Discord Python bot where I loop through a list of ForumTags and generate an INSERT INTO SQL statement for each object to insert data into a MySQL database. However, I want ...
Razzer's user avatar
  • 767
1 vote
3 answers
46 views

Converting char to date and pulling past two years data

I need to pull data from tables with millions of rows and limit it to just the past two years. I am working on developing a SQL statement to enter into Power BI to limit what it pulls. Obviously I am ...
wolfmansbrother505's user avatar

15 30 50 per page