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.

Filter by
Sorted by
Tagged with
10
votes
4answers
2k views

Materializing any ADODB Query

Following-up on Creating ADODB Parameters on the fly and pushing the "wrapping" of ADODB a step further, I have written two more classes that allows me to expose methods that don't require a ...
13
votes
1answer
1k views

A wounded Zombie finder, or: how to find the almost dead undead?

The Zombies are on their way to eat our statistics. Fortunately, we have a way to get rid of them: our votes. However, we need to find them first. The /unanswered section is too large and contains ...
7
votes
2answers
210 views

SQL Query generator, round 2

This is the second round of reviews. The first round can be found in this question. This is a project I have been working on. This is one of my first experiences with Python and OOP as a whole. I ...
8
votes
4answers
1k views

Query to find users from Australia

After a discussion of which users were from Australia, I wrote my first SQL query to find out: ...
8
votes
2answers
269 views

Local user registration

More javascript (nodejs) to go with the passport wrapper I just posted: UserBook.js ...
6
votes
0answers
536 views

T-SQL Hmac (Rfc2104 SHA2_256) Implementation

I'm trying to implement an Hmac in T-SQL using this question as an guide. Please critique this: ...
44
votes
2answers
3k views

Tired of FizzBuzz yet?

There have been many FizzBuzz questions lately, and here is one more! Granted, it is pretty straightforward to do FizzBuzz with SQL using calculations. So instead, I'm going to do a FizzBuzz which ...
15
votes
3answers
2k views

Creating an object oriented model in VBA using COM and ADODB from 2 depended SQL tables

The story... A bit of background info and how is the database designed... Please notice you don't really have to rebuild the tables in SQL but I shared an SQL Fiddle just in case and screenshots1 of ...
11
votes
1answer
91 views

The sniper: a Zombie searcher for specific tags

Sometimes, it's not enough to know what the easy prey is. You also need to know whether you will be able to hunt it down. What good is an almost turned haskell zombie if you cannot read the functional ...
10
votes
2answers
110 views

Forgotten zombie killers

Zombies are questions with no upvoted answers. I came up with this SEDE query to find answers with zero votes on questions that have no accepted answer and no answers with greater than zero score. In ...
5
votes
1answer
5k views

SQL database for a social network

I'm trying to create a mini social network mobile application kind of like Instagram and I'm not sure about my database organisation, it feels like something is missing, especially with the ...
16
votes
2answers
820 views

C++ SQL wrapper/Connection

Working on my SQL project at last. The concept is easy to use and integrate SQL into C++. ...
8
votes
0answers
150 views

Safe dynamic SQL for generic search

Prompted by discussion about SQL injection, I wanted to put a proof of concept forward to get feedback about whether this is in fact safe and protected against SQL injection or other malicious use. ...
7
votes
2answers
113 views

Put it in a bucket

You're running a jeans company. Your system is collecting detailed orders' data, but it's a bit archaic and it's storing the number of units ordered per size in a delimited string with 20 "fields", ...
5
votes
2answers
4k views

MS Access VBA code to compare records in a table and combine data where necessary

I need to process some data which is the output from a CAD system, namely a Bill of Materials. I've constructed database and written some VBA code to achieve this. An explanation of what this code ...
4
votes
1answer
5k views

MS Access VBA code to compare records in a table and combine data - revised

I've previously posted a version of this code here: MS Access VBA code to compare records in a table and combine data where necessary To repeat what I'm looking for from my previous post: Note I ...
19
votes
3answers
1k views

FizzBuzz in SQL--no loops

MS SQL Server, no loops. ;) ...
14
votes
2answers
119 views

Revision 1 - Step 1: PsychoProductions management tool project

I started a project to build my own invoicing and management system to take the place of prohibitively expensive QuickBooks software. This will be broken down in 5 steps, with the current step in bold ...
12
votes
1answer
849 views

Abusing Excel VBA… to maintain data stored in a database

I need to build a little UI to allow easy maintenance of some data stored in a MySQL database, and the end user wants to do that in Excel (I know, I know). The code I came up with comes pretty close ...
11
votes
3answers
174 views

Revision 2 - Step 1: PsychoProductions management tool project

This is another revision of my Psycho Productions database, this time refactored from MySQL to PostgreSQL, after I found out about some of the shortcomings of MySQL. The following is a (simplified) ...
10
votes
1answer
319 views

CodeLess Questions query

As part of an exercise by Jamal to clean up old questions on Code Review that have no code in them, I helped by writing this query on Stack Exchange Data Explorer: CodeLess Questions ...
9
votes
1answer
74 views

Step 1: PsychoProductions management tool project

I started a project to build my own invoicing and management system to take the place of prohibitively expensive QuickBooks software. This will be broken down in 5 steps, with the current step in bold ...
7
votes
2answers
49 views

Retrieve high views per day questions with few answers

I've been messing around with the SE Data Explorer and I've come up with a query that basically returns information about questions that have a high number of views per day, that have few or no ...
7
votes
3answers
134 views

Step 2: Creating functions the business tool will use

I've been working on this project and here is my first function for step 2. I feel this is the most important one, as I will carry over recommendations from this ...
7
votes
0answers
99 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 ...
7
votes
4answers
348 views

Multiple SQL queries, one per ID

ids contains 100 ids that are comma delimited. Is it fine or does it need improvement? ...
6
votes
2answers
151 views

Complex query to count votes with a redistribution system - follow-up

I've previously posted a question about simplifying a query to count votes with a distribution system. One of the contributors, @200_success, pointed out that it calculated the surplus redistribution ...
5
votes
2answers
9k views

Database access class

I'm looking for any comments or feedback on my database access class. Security and speed are two things I'm most concerned about. One thing to note is this class has to work in a C# .NET 2 ...
5
votes
2answers
553 views

Get data from Access SQL database with ADODB and weather data using web service

I have a program, that works, I just feel that it is running slower than it should and I feel that it is a bit more unstable than it should be. I am looking for tips on writing "better" code and ...
4
votes
1answer
4k views

Persistent login (“remember me” cookie) using PHP

The code below is a attempt to create a persistent login cookie. I am an amateur and not professional so this is the first attempt to have secure remember me cookie. Now I want you guys to review two ...
4
votes
1answer
129 views

Slow MySQL query - 1200 rows in 5secs

Can anyone help me speed up this query? At present, it returns 1200 rows in 5 secs. I've notice that it is looking at 240000 response records. I think this is where the issue may be. I've created ...
3
votes
1answer
158 views

Querying a warehouse database

Consider the query given below: ...
2
votes
1answer
2k views

SQL query generator

This question has a follow-up review posted here This is a project I have been working on. This is one of my first experiences with Python and OOP as a whole. I have written a GUI that handles the ...
2
votes
1answer
156 views

T-SQL Constant Time Comparison

Explanation is in the function. Please point out any egregious errors: ...
2
votes
0answers
52 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 ...
2
votes
1answer
2k views

Separate model from DB mapper (entity manager)

I've read that it is good to separate model from DB mapper (entity manager) (but at the end, it is perhaps personal - just a matter of opinion). Anyway, if I understood correctly, I should not have ...
24
votes
3answers
2k views

Complex query to count votes with a redistribution system

I've spent the last couple of evenings trying to build a system for redistribution of votes in a ranked voting system. I've finally come up with the model for redistributing surpluses from a candidate ...
19
votes
2answers
334 views

Naruto, where are you?

During Winter Bash 2014, the Naruto hat was awarded to users who gave an answer that got accepted but hasn't received votes for 12 hours. It was a weird thing, really: why would someone ever accept a ...
15
votes
8answers
4k views

Asking a user to take money from a checking account and move it to a savings account

I'm aiming to get this program right as I might show it at a job interview. The code below runs fine but I would like to know if there's anything that can be improved in terms of readability, good ...
11
votes
2answers
355 views

Percentage of questions that are unanswered or answered

I put together this simple query which calculates the total percentage of answered questions and unanswered questions. The formulas used to calculate these are shown below: $$ \text{Answered ...
10
votes
4answers
808 views

Listing products from a database

I've this function to list products from database by category. I'm using prepared statements, but wouldn't this make it pretty pointless to use them? ...
10
votes
1answer
2k views

SQL Tic-Tac-Toe attempt

In an attempt to practice conditional statements in SQL I decided to design a tic-tac-toe game with MySQL. Let me know if you think any of the steps could be done better. Step 1: Create the game ...
8
votes
4answers
573 views

Bad practices in this procedure to calculate player statistics?

I recently self-taught myself MySQL as quickly as possible because it was needed for a project that I'm working on. Now that I've got some time I've been working on improving some thrown together SQL ...
8
votes
2answers
143 views

Finding questions to answer

In light of the recent "SQL frenzy" of sorts in The 2nd Monitor, I decided to take a stab at writing my own SEDE query. Essentially, what it does is find questions that could be answered based on the ...
7
votes
2answers
556 views

Modifying `sakila` database

This is not "real life" code. I'm trying to expand upon the well known Sakila sample database for MySQL to make it more complex. Step 7 (or 6) is running ...
7
votes
1answer
168 views

Do you Connect with my Groove?

I'm new at groovy, and this is my first time writing a database connection script. It may seem like example code, but it is more like test code. It works as posted, and I'm planning to use this as a ...
7
votes
0answers
220 views

Executing dynamic SQL programmatically

Usage (all parameters are optional): ...
6
votes
2answers
59 views

1st questions with answers within X hours

I recently challenged @Hosch520 with writing a query as such: Find first questions with answers posted within 24 hours And he did great. I figured I would have a go at it too. Turns out I learned ...
5
votes
1answer
427 views

MySQL IMDB Query Speed

I'm using data from a database from the IMDB website. The database consists of five relevant tables. Actor (id, fname, lname, gender) Movie (id, name, year, rank) Director (id, fname, lname) Cast (...
5
votes
2answers
74 views

Conditionals for time specific data (SQL style)

I was inspired by this question from @AndyRoid to try and come up with some fast and accurate datetime calculations that didn't involve complex if/...