Structured Query Language (SQL). For questions about the language, not Microsoft SQL Server (tag sql-server).

learn more… | top users | synonyms (2)

4
votes
2answers
149 views

Update old database with SQL dump

I had to recover a database with a some months old full backup. I have however in my possession a most recent but unfortunately incomplete SQL dump for this same database done with mysqldump. Is ...
-2
votes
1answer
35 views

Finding the mismatch column names

I have two datasets, both having same column names and just one row. I want to display the column names for which there is a mismatch of column values. Could anyone please suggest how this can be done....
1
vote
0answers
12 views

How to show when loan was paid off

First time posting but have been a reader for over 10 years. I have a need to show when a loan was paid off regardless of the rolling balance from refinancing/taking out additional loans. In the ...
0
votes
1answer
11 views

SQL Server - Select last value given a date

To make it easier, I have data that looks like this as an example: What I am trying to return is the Amount of the Balance Update as of a specified Date for each Investor_ID. For example, if my ...
0
votes
0answers
5 views

SQL Sum column til value and then increment group and continue summation

I've run across an interesting problem that I'm not sure how to tackle. I've been charged with finding a solution to the following scenario, and I'm not really sure where to go with it. Here is the ...
0
votes
1answer
12 views

SQL Server: Msg 512, Level 16, State 1, Subquery returned more than 1 value

This has me baffled, as I have tested multiple variations of the correlated subquery to no avail. Since the MAX function is suppose to guarantee a single result, I'm almost convinced that the problem ...
0
votes
0answers
17 views

UNION Query rendering 2 columns

I am using Access 2013 SQL. I have the following query qry structure: SELECT TOP 10 [Sub Category] AS Category_1 FROM tbl WHERE [Category]='1' GROUP BY [Sub Category] ORDER BY SUM([Value]) DESC; I ...
0
votes
0answers
26 views

I need to merge two queries with condition

I have the following query: SELECT URYRR_FORWARDS_REC_H.CB_LINE as "CB_LINE", URYRR_FORWARDS_REC_H.CB_LINE_DESCRIPTION as "DESCRIPCION", URYRR_FORWARDS_REC_H.UYU_BALANCE_FW as "MONEDA LOCAL", ...
0
votes
1answer
28 views

How to connect to an Oracle db using a stored procedures within a Microsoft SQL server? [on hold]

I need to verify data between an Oracle db and a Microsoft SQL Server db to verify that if there differences between the two and then update the Microsoft SQL Server with any changes there may be. ...
0
votes
0answers
15 views

Can SSMS or SSDT validate and insert security objects?

Can Sql Server Management Studio validate and insert security objects (roles, schemas, asymmetric keys, certificates, users, and so on) both at the server and DB level?
0
votes
1answer
47 views

Database design considerations for unused columns with every table has same schema

I am a web developer so I don't know a lot about databases. The company I joined recently has a very mature Desktop ERP built in .NET and SQL Server, they are providing services to huge corporate ...
0
votes
0answers
16 views

I want to make a website similar to Udacity, Coursera e.t.c. for online courses. Which technology should I use for storing the course information? [on hold]

I am mainly confused between storing the information of a certain course in an SQL Database A JSON / XML file for each course which will then be stored in a file storage system and can be retrieved ...
1
vote
1answer
60 views

Joining Tables in the FROM vs. the WHERE clause [duplicate]

First time caller here. I have a question regarding best practices when joining tables. For example, both of the following queries return the same results: SELECT i.id, p.first_name, p.last_name ...
-3
votes
2answers
87 views

How do I find mismatches in two tables?

I have a database where I'm trying to find inconsistencies across two tables. I'm new to SQL and would like some help. The other questions I've looked up are confusing and too convoluted for what I'...
-1
votes
1answer
19 views

How can I create a church attendance report system?

Please am pretty new to php and mysql. I have an assignment to create a church attendance system for our weekly services. The system would be able to know how many males and females came to church ...
3
votes
1answer
20 views

Can SSDT deploy SQL server service broker objects?

Can SQL Server Data Tools (SSDT) deploy sql server broker objects? (So contacts, message types, services, queues and so on.)
0
votes
1answer
16 views

Modeling Optional Column

I've got an optional column (residential) in one of my tables that is giving me trouble. If a Licensee intends to work w/ residential customers, they need to take an additional course (...
6
votes
1answer
12k views

Optimizing large database query (25+ million rows, using max() and GROUP BY)

I'm using Postgres 9.3.5 and I have a large table in the database, currently it has over 25 million rows and it tends to get even larger rapidly. I'm trying to select specific rows (all unit_ids with ...
0
votes
1answer
113 views

MS Access Run Multiple Queries

I have eight 'append' queries in MS Access 2010 that I want to be able to run. Each query also needs to take one parameter (a project number). I want to run all eight, entering the parameter only ...
4
votes
1answer
5k views

Split comma separated entries to rows

I have a Table like this: | ID | OtherID | Data +--------+-----------+--------------------------- | 5059 | 73831 | 5103,5107 | 5059 | 73941 | 5103,5104,5107 | 5059 | 73974 | ...
0
votes
1answer
149 views

How to group records in mysql query

I have a table (user_access) with the following columns in mysql database id int user int access_time datetime I am trying to run a query that gives me the number of times users accesses ...
0
votes
0answers
7 views

postgres create a view with data transformation rules

I was hoping someone could point me to a resource that can help me solve my problem. I have a largish dataset (25 Million rows), and I need to export the table based on a set of rules. 6 rules to ...
3
votes
2answers
2k views

Differentiating tables and views in INFORMATION_SCHEMA.COLUMNS

I have a view which selects information from INFORMATION_SCHEMA.COLUMNS, which seems to give me both columns and views. Is there an easy way to tell which rows are columns and which are views? Should ...
2
votes
2answers
239 views

Splitting 1 record on one table to become two records on another table

I am REALLY very new to this so please excuse my ignorance, but I could really use some help! I've got two tables: BillsFiled and Authors On BillsFiled, there are the columns: ID, Symbol, Filedate, ...
0
votes
1answer
24 views

Updating and/or inserting several rows in the same SQL statement

I am implementing an account "ability" type thing - a users account is given the abilty to do one or many things in the system, like (simple examples) cancel orders or pay invoices. I have a table ...
0
votes
2answers
503 views

Oracle Error: the sga requires more space than was allocated for it

(Oracle SQL 12c running on Windows 10) My installation has previously been working fine. I was trying to set up one of my tables to use the In-memory option available in 12c. I was following this ...
15
votes
2answers
609 views

Does any DBMS have a collation that is both case-sensitive and accent-insensitive?

Note this question is vendor/version agnostic It seems to me, as a speaker (typist, writer) of English, reasonable to expect words to be properly cased but not necessarily have the correct accents ...
1
vote
2answers
170 views

Get first and last record for each date and calculate their difference

I need to calculate the DATEDIFF in seconds between the First record for each date with EventCode = 1 and the last record for each date with EventCode = 2. I have posted a sample data set for 2 days ...
0
votes
0answers
23 views

Finding records only when all ids present in a group

Having these two tables id | val TableA -------- 1 | A 2 | B 3 | A 4 | B 5 | A 6 | C 7 | D id_A | data TableB ----------- 1 | a 2 | b 3 | c 5 | d 7 | e First I ...
0
votes
1answer
313 views

How to use explode mysql function in where condition with cakephp

I am using cakephp 2.6. I have payment_method fields in mysql table which store the values like 54,52,59,57 . Now my question is that how can i check if new posted payment method id is available in ...
0
votes
0answers
14 views

why execution time change between each run

I have a pgAgent job connecting to a remote server: Every minute bring ~400 records. Job take ~500 ms Result are save in avl_pool (avl_id, x, y, azimuth, near_link) last one is null here I ...
0
votes
0answers
13 views

Design: Available domain database

I'm building website and service that will allow user to check if given domain is available. Right now I'm thinking about good way to store result from whois, but i dont want to store whole response ...
0
votes
0answers
30 views

SQL Retrieval Into Excel HELP! [on hold]

The picture shows the format of E1 to maybe help out visually. I'm an intern and I work for an engineering company. As a project, I want to streamline the document control [DC] process and save time. ...
0
votes
3answers
29 views

Page life expectancy very low on certain time?

Everyday we receive an alert on a specific period (03:00 AM - 04:00 AM) indicating that Page life expectancy is too low : SCOM :Alert: SQL DB 2008 Engine Page Life Expectancy is too low We have ...
0
votes
0answers
38 views

SSIS all executions report query

At first - hello DB specialists! I'm trying to prepare a query, which in result give me a specific information about SSIS jobs and errors if occurs. I found some hints on google and finally I have a ...
1
vote
1answer
131 views

Slot Time Challenge - Doctor Appointment database schema

I am trying to make a doctor appointment system where patient online will have two options: First time visit (this visit should be 20 mins) Follow up visit (this visit should be 10 mins) ...
0
votes
1answer
26 views

How to store data having a fixed number of columns and a variable number of rows

I have posted this question in the stack overflow site and a more experienced user than me suggested I post it here. I am quite new at collecting data and am collecting a new dataset using R from ...
19
votes
5answers
91k views

Can I see Historical Queries run on a SQL Server database?

Someone was running a query on our SQL Server database remotely and their system crashed. They have no backup of that query and want to see what was run on the server. Is it possible to find this ...
0
votes
0answers
22 views

mysql select duplicate columns for same row

Ok I'm trying to write a customized report for a preexsiting database(IE, I didn't design it and can't change the convoluted structure) that has a user table and 2 other tables that store user ...
1
vote
0answers
18 views

Join Tables of Varying Criteria in Order of Priority

I am trying to join two tables based on varying criteria in order of priority. The situation I have inherited a clinical database which has inherently bad data quality from years of poor input and ...
1
vote
1answer
53 views

SQL parsing XML

I'm receiving XML files as part of an EDI setup and I'm having an issues getting information from the child elements. Here is the XML file: <?xml version="1.0" encoding="UTF-8"?> <cpi_event&...
2
votes
1answer
374 views

Database Mail not sending

I'm trying to send email using the DatabaseMail on SQL Server 2008, I can see my emails sitting in the msdb.dbo.sysmail_unsentitems But they just sit there, I get no error messages. I've checked ...
0
votes
2answers
20 views

SQL server after RAID problems

We had a SQL server die due to some RAID problems. We sent the machine out to a data recovery company and they are able to recover the .MDF and .LDF files from the drives. Will I be able to use ...
2
votes
2answers
335 views

MySQL Escape Characters

I'm getting an SQL error when trying to mix a match against in a SQL statement with a specific character which is not covered by MySQL escape functions in PHP. This is an example: The name to ...
1
vote
2answers
4k views

Cannot Add Foreign Key Constraint

Can anyone tell me why there are errors such as: Cannot Add Foreign Key Constraint And am I on the right track? My schema looks like this: DDL: DROP DATABASE technology_university_hospital;...
0
votes
1answer
25 views

Join query result of 2 different tables based on common column

I want to join the result of two different queries from two different tables based on a common column (which is named differently in the two tables) but I cant seem to figure out the easy way to do it....
2
votes
1answer
57 views

Calculating a percentage discount in SQL [closed]

Basically just started using sql and having a minor problem. Working out the percentage of a number. Example: What would I need to type in to work out: 2.75 - 5% Drink_price= 2.75 After 5%...
0
votes
1answer
29 views

SSIS: Import Excel file to SQL Server

Is there a Excel version for this article? I have been searching for this past days but there is no luck. https://www.simple-talk.com/sql/ssis/ssis-basics-introducing-the-foreach-loop-container/
1
vote
1answer
155 views

Finding out the exact size of the database after inserting records?

I have this query: SELECT table_schema "db.name" , Round(Sum(data_length + index_length) / 1024 / 1024, 1) "DB Size in MB" FROM information_schema.tables GROUP BY table_schema; Does this ...
12
votes
3answers
9k views

Best way to design tournament database

I'm creating a webpage for placing bets on all matches of the upcoming Euro 2012 football tournament. Need some help deciding what approach to take for the knockout phase. I have created a mockup ...