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
14 views

Python and SQL - Query takes too long to execute [on hold]

I've recently began to work with Database queries when I was asked to develop a program that would have read data from the last 1 month in a Firebird DB with almost 100M rows. After stumbling a ...
1
vote
0answers
12 views

Iterate between dates and INSERT values in a performant way

I have created a query that populates a datapoint with random values. The logic is simple: Iterate between the START and END dates and INSERT random values. I want from this query to be very ...
0
votes
0answers
31 views

SQL SP creating certificates for shipping

We ship large spools of copper wire and pallets of copper rod that have to meet specific chemical and mechanical requirements, this is what must be put on the certifications. I created an SP which ...
3
votes
1answer
52 views

Generating report columns from SQL query

I've written this class to create RapportColumn objects for each column that is written in the query. And I would like to get your feedback. The query that is ...
-3
votes
0answers
13 views

SQL sort by and include only most recent column [closed]

What I have so far is this: Name : Date Person A : 21/Aug/2017 Person B : 04/DEC/2015 Person C : 30/NOV/2013 Person A : 21/AUG/2012 and so on .... And what I want it to show me is just the MOST ...
1
vote
0answers
35 views

New comments after a user's last comment

Edit: I've added everything I can... I have the following query, which gets the last comment from the user in a given topic, then I check in the while loop if there are newer comments. My problem is,...
3
votes
1answer
31 views

Static class for database access Java JDBC

I'm writing a small program to store data in a database (a discord bot mainly). I know cleaner ways of using dependency injections and DAO exist, but I haven't written a DAO (or the user class) and ...
2
votes
0answers
27 views

SQL query that extracts a topic keyword from article titles

I have a query like this to select the only row with title contains specific programming topics. ...
0
votes
0answers
14 views

Get chat message data from table, grouped by date

Giving the following table: ...
2
votes
0answers
54 views

PHP + PDO - Inserting data on the table with a loop

First of all i made a simple code to insert data on my table, with the information from this code i made a loop to insert data on another table for a notification system. I'm new to PHP and i think ...
0
votes
0answers
3 views

Crystal Report Selection Formula with several if else statements

Below is a record selection formula we use in one of our crystal report. As you can see, there are some if else statements, how do I simplify this? ...
0
votes
0answers
10 views

Performance of TSQL to generate national insurance numbers

I have written some SQL that generates "valid" national insurance numbers, they need to be "valid" in order to pass third party checks which take place on the test data that they are included in. ...
1
vote
2answers
179 views

Using decorator and strategy pattern for dynamically generating SQL queries

This is a link to my application that actually runs on the design specified in the image. The idea behind the image is that the SubjectInfoViewer behaves as the ...
-1
votes
0answers
64 views

Gym application

I currently want to create my first project app, that will help user to start an adventure in a gym. The code that I provided is for set by given earlier value the spinners with body parts. I've got ...
0
votes
0answers
34 views

My own login system for a PHP website

I have a website which has its own login system. Passwords are properly hashed, SQL statements are prepared statements and the like. I'm currently working on a few scripts which let users edit their ...
0
votes
0answers
13 views

Retrieving all posts from boards that a user's subscribed to

Here I have a scenario where a user can subscribe to a message board and receive all posts created from that board. There's only one stipulation, which is that posts created by the subscribed user ...
2
votes
1answer
55 views

Find all shortest paths between 2 nodes in a directed, unweighted, SQL graph

I want to find all shortest paths between a pair of vertices in a unweighted graph i.e all paths that have the same length as the shortest. The edges of the graph are stored in a SQL database. The ...
1
vote
0answers
17 views

Activity grouping and selection according to order and completion requirements

The problem consists of two categories of events (Work and Rest) which together form a complete set. The number of Work events is open-ended. The number of Rest events is fixed at three (3). The ...
1
vote
0answers
28 views

Simple web API that access sqlite database

This is a very simple web API for a school assignment, as a part of a bigger system. The web API returns a list of courses or a single course as json. I doubt that I will get any feedback on the code ...
2
votes
0answers
26 views

Upsert query using CTE in PostgreSQL 9.4

I have a generic pipeline in SnapLogic that logs the start time of the executions of a group of incremental jobs. Suppose, the log table is as follows. ...
0
votes
1answer
39 views

Updating 3 columns conditionally on a database table

I need to run this script to update the value of 3 columns based on certain conditions. Right now, this is what I have: ...
0
votes
1answer
31 views

Simple PHP project to store inputs in MySQL and output them

As my first simple PHP project, I've created a simple project that allows you to just enter your name and two numbers, where it displays them on the page and stores them in a database. It consists of ...
3
votes
0answers
26 views

SEDE query to calculate net migrations quarterly from ELU to ELL

Over on EL&U Meta, someone raised the question of how many net migrations there are to/from our sister site, ELL. The following SEDE query calculates the net migrations by quarter (...
0
votes
0answers
7 views

Dynamic Statement Executor

I've written a stored procedure in order to simplify the process of calling dynamically constructed MySQL statements: Implementation ...
1
vote
0answers
49 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 ...
1
vote
1answer
28 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 ...
2
votes
1answer
73 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
94 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 ...
-5
votes
1answer
56 views

How to write SQL in a industry standard style [closed]

Here are the commands I ran to start setting up a database I need. ...
2
votes
0answers
30 views
0
votes
2answers
69 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 ...
1
vote
1answer
38 views
1
vote
0answers
41 views
0
votes
1answer
60 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
64 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
34 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
109 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
32 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
53 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
137 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
81 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
95 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
77 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
46 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
50 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
59 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
63 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 ...