Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [sql]

Structured Query Language is a language for interacting with relational databases. Read the tag wiki's guidelines for requesting SQL reviews: 1) Provide context, 2) Include the schema, 3) If asking about performance, include indexes and the output of EXPLAIN SELECT.

-1
votes
0answers
42 views

SQL Server Express 2017 INSERT SELECT Performance Issue [on hold]

The current problem description is as follows: I have uploaded two files on OneDrive. File 1: "script.zip"(1.5 MB) Link is: https://1drv.ms/u/s!AuV9gXqFVffxhEQgLpnrQ79O0cf8 File 2: "...
1
vote
0answers
22 views

Kotlin DAO with Exposed: How to reduce redundancy in classes?

I'm writing a Kotlin app that uses Exposed (https://github.com/JetBrains/Exposed) as a SQL wrapper to write and read objects from databases. The problem I'm facing is that I end up with 3 classes ...
0
votes
0answers
15 views

Retrieve sum of specific bitarray sequences

I have a table that has the following data: ...
1
vote
0answers
16 views

Loop Through bitarray to retrieve subsets of that bitarray

Objective: I want to loop through a bitarray and store subsets of that bitarray in a table. Context: I have a bitarray with 48 elements where each element represent one hour. I want to look back 24 ...
0
votes
0answers
9 views

MySQL EAV structure and query

I have designed a EAV table structure as follows: ...
2
votes
1answer
67 views

Repository of trainers

This is my first asp.net core web api and i did followed the Repository pattern but i don't know whether this approach is good practice. ...
1
vote
1answer
77 views

Inserting data into SQL-Server table dynamically

I know I can do all this via SSMA quite quickly, but I wanted to see if I could do it efficiently in PowerShell myself as a little project. Basically, the entire script takes tables from an Access ...
-4
votes
1answer
37 views

How to write SQL in a industry standard style [on hold]

Here are the commands I ran to start setting up a database I need. ...
1
vote
0answers
24 views
0
votes
2answers
57 views

Use a comma-separated field in another SQL query

I was just wondering if there was a better way to write this block of code in php. I have a string with values separated by commas. I need to prepare that string to pass it on to the query using IN ...
0
votes
1answer
32 views
0
votes
0answers
34 views

Simple Search System using Method “POST”

index.php ...
0
votes
0answers
32 views

Insert into database from three different queries

I have 3 tables: user_group_insurance user_insurance user_policy_group How could I ...
1
vote
0answers
34 views
-1
votes
0answers
33 views

Oracle SQL query- need to reduce response time

I wrote a query which fetches the record of NULL DAYS (Occasion, weekoff, emergency holiday). Later I implemented the same in GUI, so my admin can able to see the list, it will take minutes to load ...
0
votes
1answer
51 views

SQL Stored Procedure to export specified data

I'm currently using a stored procedure(sproc) to export to Excel. The sproc is being passed ...
2
votes
0answers
63 views

Insert items from one table that do no exist in the other one [closed]

The insert query below must insert the items not present in the Articolo table by importing them from Importazione, and must update the items in the Articolo with those present in the Importazione. To ...
1
vote
1answer
31 views

Calculating COUNT(*) of a MAX() + GROUP BY query

I have a SELECT query I'm executing which has a MAX() column and a GROUP BY clause, and in ...
2
votes
1answer
84 views

ToDoApp - adding users, managing tasks, getting tasks

I've implemented a console ToDo application. I would like to hear some opinions about it, what should I change etc. About project: It is intended to manage everyday tasks. Application contains: ...
0
votes
0answers
19 views

Splitting search terms

My problem is, that I want to take a search string, and split it into keywords. I have a function function search(array $keywords) that generates an sql along ...
1
vote
0answers
28 views

Implementing an In-house Badminton Ranking System

I am working on a project and wanted to have a quick look by you people if the schema or query needs some changes or does it totally needs to be changed. The project is about creating a ranking ...
0
votes
0answers
16 views

Go SQL relationship scanner

I have written a function which takes in an sql.Rows instance and returns an array of model.Trip instances derived from the rows....
2
votes
0answers
48 views

One class for MySQL and MSSQL Queries

EDIT BELOW I am trying to create resusable classes for MSSQL and MySQL queries (later also Update and Delete queries). I tried it doing the OOP-way. Here is my result: Einstellungen.vb: ...
1
vote
0answers
115 views

Stored procedure that adds row-level auditing to a table

I'm looking for any suggestions on how to improve my T-SQL for this procedure. It works okay, but I'd like to get advice to improve it from more experienced SQL developers. This procedure adds 4 ...
0
votes
2answers
74 views

SQL Statement with a Select Statement Inside a Where Clause

Is there a more efficient way to write the following PLSQL statement? It seems inefficient to me to have the SQL statement nested inside the where clause. ...
3
votes
1answer
94 views

Running SQL Queries On A Worksheet (With Set Of Random Numbers Between 1-20 Filling Column A) Handled As An ADO

INTRO I am using an Excel worksheet as my "database." No headers so [F1] is assigned to column one by default. I filled the entire column, all 1,048,576 cells with ...
3
votes
1answer
71 views

Project management query for various organizational units

I use the code below to calculate the required information from other tables. I used joins to display names instead of IDs and to get required sums from other tables. I used ...
2
votes
2answers
44 views

Dynamically displaying or hiding checkboxes based on region selection country. Also select All / None included

This is basically my first real venture into JS coding ... I think what I have put together here is quite long-winded and could be streamlined but I'm not quite sure how. So I have a table with ...
-3
votes
1answer
49 views

Is there a different way of implementing this program without using nested while loop? [closed]

Presently my program is working properly, but how do i implement this program without using nested while loop(one while loop within another while loop).This is a kids way of programming and my office ...
1
vote
1answer
53 views

Calculate NPS in a stored procedure

We collect customer surveys and one of the questions is the dreaded "How likely are you to recommend our service?" question from which we calculate a Net Promoter Score. (I hate this calculation, but ...
0
votes
1answer
60 views

SQL Query to get parent parts of materials using Recursive CTE

The intent of the query is to filter out certain materials to get to a list that will then be run through a recursive CTE to drill up through the BOM to the 0 level assembly. P_Parts_CTE is filtering ...
2
votes
0answers
38 views

SQL/PHP Laravel - Looping through records to find relationships

I have two tables in my database, which contains a big list of organisations. They are called orgs_main and orgs_sub. This is ...
4
votes
1answer
86 views

Retrieving a product's sold quantity

I've written a view to retrieve each product's sold quantity and four week sales average by Branch/Route/...
2
votes
2answers
47 views

Stored procedure to implement a search filter

I've implemented a stored procedure for a search process SQL Server 2008. I'm not sure if everything I created is correct. Also I'm wondering if this code has any leaks or vulnerability on SQL ...
-3
votes
1answer
45 views

3 tables in SQL [closed]

Lets say i have 3 tables: users, posts and comments. ...
6
votes
2answers
90 views

Find how much reputation a user had on a given date

I saw this question on MSE and went ahead and wrote a solution to it: https://meta.stackexchange.com/questions/313561/determining-users-reputation-as-of-particular-date This calculates the ...
1
vote
1answer
31 views

Worst Query performance issue on date calculation

I have a stored procedure that is taking more than 2 hours to complete and I noticed the below SQL is taking close to 25 mins for updating a million+ values.There are multiple steps like this and all ...
2
votes
1answer
30 views

Query to find instances of two types of events occurring more than one second apart

I have 3 tables on my database: BusinessObject and CustomEvent, and EventType. ...
3
votes
1answer
37 views

Stored procedure for sending emails at specified times after license expiration

I need to send email notifications for expired licenses: One Day Before/After Expiration Two Days Before/After Expiration Three Days Before/After Expiration One Week Before/After Expiration Two Weeks ...
2
votes
0answers
43 views

Calculating effective shop inventories (SQL)

This is an SQL version of that question. Shops and groups The problem domain is a collection of shops (identified by an int shop_id number) each of which is ...
1
vote
3answers
59 views

Login module with JDBC

I made simple login module that is responsible for handling registration, and signing in my application. How can I improve this code? Are there any conventions for this case? The idea is to create ...
1
vote
1answer
335 views

Basic object-oriented PHP login, logout, and registration scripts

I am new to OOP in general and have recently started trying to develop object-oriented PHP code instead of relying on a primarily procedural style, as this is a requirement for my studies. One part of ...
1
vote
1answer
307 views

PDO Dynamic query builder

I'm trying to improve my php oop programming skills. As an exercise I wrote this class that will generate and execute dynamic sql queries. I've also writed a class to call various sanitization filters ...
0
votes
0answers
24 views

Querying 2 or more tables with joins or eloquent relations

I have few tables that store the details of educational content within a school. Tables' descriptions viz. A grades table stores all grades, subject table stores all subjects, ...
1
vote
1answer
63 views

HTML file with a submit form

I have an HTML file that contains a submit form, which asks the users the fill in their personal info: then it will post and store into the DB by method of PHP SQL: ...
0
votes
0answers
12 views

Filtering query by date built from integers - how to make more readable

I am trying to make stored procedure and pass some parameters for filtering. As soon as filtering is in horizon, code has to be as generic as possible with less as possible if else etc. How could I ...
4
votes
2answers
28 views

Select recordIDs for Bill of Materials

I have a hierarchy of parts in my database. For example, one part (call it 0010102-0112-315) is a resistor. It's used in a billion different top-level assemblies. ...
-1
votes
2answers
100 views

MySQL select between MAX-n1 AND MAX-n2

I just made this link please check this out Online Results I need to select data between 2 values from a table by using MAX because each SID has different VID. My code: ...
7
votes
0answers
65 views

Science Fiction Wall of Fame (Shame?)

I have a few of hobbies, one is reading science fiction and fantasy and another is coding solutions. I thought I might have a chance to combine both hobbies on this project. I have well over 1500 ...