An acronym for "Structured Query Language" (it's not the name of a specific DBMS product), SQL can be used in relational database management systems (RDBMS) to query, update, delete, and insert data as well as modify the structure of the database. It can also be used to manage schemas and data ...

learn more… | top users | synonyms (1)

-1
votes
3answers
126 views

How to load multiple values in cell from Excel to SQL Server many to many table [closed]

I have values in excel like this. StudentNumber| Subjects 1| english, science, maths 2| maths, biology 3| history, zoology I have Student table in database ...
2
votes
2answers
63 views

Call UPSERT function multiple times to different inputs

I have a function: merge_vehicles(vid, cid, vname, reg_no, name, name_1st) Can i call it multiple times on inputs like (2335, 55, '246BDH', '246BDH', '811', 1), (2336, 55, '038THX', '038THX', ...
0
votes
1answer
25 views

moving binary database folder is causing issues with innodb tables

so I have a mix of myisam and innodb tables on a database. (its a pretty big db 30gb) I copied the folder of the database from one server to the next /var/lib/mysql/databasename well the myisam tables ...
3
votes
2answers
94 views

Why postgres is using an odd index with no relation to the query

(Debian 7, Postgres 9.3, dedicated machine with huge cache) I have one big table called process_data (14gb) and another tiny lookup table called process_location. I'm doing a query between these two ...
1
vote
0answers
36 views

Increasing 4 vCPUs to 8 vCPUs [closed]

Can anyone share their experience if they encountered any issues trying to provision extra CPUs for SQL Server running on VM ?
0
votes
1answer
27 views

multi-column FKs with NULL values

I understand that in PostgreSQL if there is a multi-column FK from table B to table A and one or more of the FK columns in table B are nullable then the FK is still considered as "honored" for the ...
0
votes
1answer
24 views

MYSQL improve query performance when using OR

I have a very simple MYSQL table with 2 columns and I run this query: SELECT * FROM table WHERE (col1 = '123' AND col2 = '456') OR (col1 = '456' AND col2 = '123') Col1 and ...
1
vote
2answers
27 views

MySQL improve query syntax

I have this simple MySQL query: SELECT * FROM table1 INNER JOIN table2 ON table2.col = table1.id WHERE table1.id = '123' id is the primary key in table1. table2 has composite primary key of two ...
0
votes
1answer
18 views

“No Current Record” when using COUNT() in Access 2010?

Okay, so, I'm trying to get a count of how many customers each service provider has billed for over the last year or two. Our database's data is slightly imperfect, so I'm trying to kludge together a ...
0
votes
0answers
29 views

Crazy SSRS Issue

We are working a data center migration and are to the SSRS boxes and I am having trouble. SSRS is installed on a server alone pointing to the ReportServer and ReportServerTempDB on a different SQL ...
0
votes
1answer
28 views

MySQL - Arrange a table so that it shrinks as much as possible?

I'm a newbie and I have +10 million articles(200 to 1000 words) in a InnoDB table. I use this to select them: SELECT article,title,other_fields from table where id=123; There is no full-text search ...
-1
votes
2answers
51 views

about latest row in sql server

I have table like id name When I inserted new row after that, I want to know which is the latest record in my table .. How to write a query for this ? I don't want to use any primary key or ...
0
votes
1answer
52 views

Oracle Nested Query with Group By and Having Clauses

So here's the question Find the IDs of aircraft which have flown more distance for a destination than the average distance of all flights for that same destination Here is the schema ...
0
votes
1answer
166 views

Stored procedure to compare two columns from different tables and make the insert

I have two tables: Project with fields fld_id (integer), fld_allocated_hours (integer), fld_project_id (integer) Timesheet with columns fld_id (integer), fld_allocated_time (integer), ...
1
vote
0answers
62 views

Optimizing SELECT queries

I'm not very experienced with database query optimization. I've been reading through similar questions here and Postgres tuning articles online, but unfortunately I haven't had any luck. Here's what I ...
0
votes
0answers
31 views

How to insert a row which contains a foreign key in mysql

Here's the original question regarding PostgreSQL. I'd like to know of a similar solution for MySql. The simplest syntax provided in the answer works fine as long as the relevant rows already exist ...
1
vote
0answers
28 views

MySQL not using multicolumn index on self join

I'm trying to optimise a query that performs an inner join with itself. The table size is currently 10GB ~50 million rows. /* Count all occurrences between start and end site id of a given speed ...
0
votes
1answer
21 views

For each record, count records dated earlier in PostgreSQL

I have a table that contains a column year. I need, for each row, calculate the number of entries where the year is less than that in the row. So that the output would look like: col1 | col2 | ...
0
votes
0answers
32 views

How can I import “.sql” file into a new database? (using Python or even IPython)

all! I have a "bakupdb.sql" file which contains tables from a web page (created with Django) and some data (that is inserted into the tables). It's a dump back up data. I don't have anything else - ...
-3
votes
1answer
101 views

Best design to handle multiple query keys [closed]

I am designing a postgresql database for an online card game. I want to provide users with the option to access their play history - users can see log of their games. The data I want to save has the ...
1
vote
1answer
68 views

SQL Server Query performance with window function

We write a query that include unpivot, partition by and order by.Query is: SELECT PersonId ,SalaryDate ,ID ,Type ,SalaryValue ,ROW_NUMBER() OVER ( PARTITION BY PersonId ...
0
votes
1answer
44 views

Steps or evaluation order of the SQL statement

How the SQL statement containing simple statement like Select x From y Where z Having, order by , group by etc. are evaluated.( In which order they are evaluated.?)
0
votes
0answers
21 views

Intermittent MySQL 5.17 issues - extremely slow queries

I am experiencing major issues with intermittent mySQL issues. To give some background the website runs optimally for the majority of the time, however 3-4 times a day queries that should take a split ...
0
votes
1answer
34 views

COUNT() and link between tables

I have some difficulties to make a query. Basically, I have a 3 tables: member, build and up: member --+--- id|... build --+-----------+--- id|member (fk)|... up --+-----------+--------- id|member ...
1
vote
1answer
49 views

How to sort rows to appear alternatively (e.g. A B A B … )?

Suppose I have a column x with values A and B. For example, Row X 1 A 2 A 3 A 4 B 5 B 6 B Now, I want to sort them into this fashion: Row X 1 A 2 B 3 A 4 B 5 A 6 B Of ...
0
votes
1answer
38 views

SSRS Domain Migration

My company is currently going through a data center migration. We are now down to the SQL Servers and this includes SSRS. The bad thing that is going to hit us is the current SSRS server is being ...
0
votes
2answers
173 views

Error Grouping By Multiple Columns using CASE

Is it possible to group by multiple columns in a CASE statement? I get error "Incorrect syntax near ','." in below code... SELECT CASE WHEN Type = 'Test' THEN Description ELSE ...
0
votes
1answer
46 views

In a banking organization, why would account balance be declared as varchar and not decimal?

I worked in two organizations where I found money related columns are defined as VARCHAR data type. I didn't get correct explanation from anyone. As the database team is totally isolated with our ...
0
votes
1answer
28 views

Only Filtered condition gets deleted from index after datatype change using SSMS

In SSMS if I create a filtered index we can see filtered condition in index properties. But if I change column type of a column involved in filtered index using SSMS , then after column type changes ...
0
votes
1answer
51 views

12 hour format time in SQL datatype

I can convert time datatype to 12 hour format using convert etc. But is there any option to save the time in 12 hour format in SQL tables using any settings or property or any other methods?
0
votes
1answer
32 views

Reducing size of datatype involved in index fails where as increasing size work

This question is related to my previous question Database events that will cause deletion of index For example if i create a table like CREATE TABLE dbo.Customers (ID INT IDENTITY(1,1) PRIMARY KEY ...
0
votes
1answer
16 views

How can I Use Access to combine tables of information

I have two tables in access with a common ID number in both. One table has mail to info and the other table has account information. The account information can have multiple listings per ID. The mail ...
5
votes
3answers
453 views

Speed of MySQL query for the most recent 800 entries in chronological order

I have a MySQL database running on an Ubuntu box that pings 250 clients once a minute (24x7). My column names are: ip_address varchar(16), status varchar(7), timestamp datetime Been running it for ...
-1
votes
1answer
52 views

SQL Server 2008 Trigger

New to triggers. I have two tables. One for users & other for circulated mails. The circulated mails table has [Sender, Receiver...] users table has [Personal Number, Names, Email]. when we have ...
1
vote
1answer
39 views

Append duplicate records with count (mysql)

We need to update a set of titles that have some duplicate entries. Because of the size of the database I would prefer to use direct mysql method, but I am open to any solutions out there. If we have ...
1
vote
1answer
83 views

SQL Azure Performance of new servers

I have a fairly small database ~200MB which when running in the web edition of SQL azure is lightning fast. I've switched it to the basic edition and all of a sudden a group of queries which took less ...
1
vote
1answer
49 views

Composite Foreign key to single primary key [duplicate]

How do I create a composite foreign key to a table with a single primary key? For example suppose I have the following tables: CREATE TABLE Branches ( BranchId UniqueIdentifier DEFAULT ...
0
votes
1answer
26 views

Connect by prior - multiple fields and query efficiency

I have 2 tables one of which defines the hierarchy for the other equipment id desc 1 item1 2 item2 3 item3 4 item4 5 item5 6 item6 7 item7 8 item8 ...
0
votes
1answer
25 views

Time Series data for controllers connected to other devices [closed]

We have a relatively large number of controllers deployed to the field (4500). Each of these controllers have multiple other devices connected to them. These controllers are now going to be able to ...
2
votes
2answers
122 views

Good way to restructure a table

I have a number of tables in an existing database that i would like to migrate to a new database but with a little different structure. For example if a current table has columns like below: table1 ...
0
votes
1answer
74 views

How to insert values in junction table for many to many relationships?

I have three tables in database: trips(trip_id(pk), trip_name(unique), user_id(fk)) places(place_id(pk), place_name(unique)) trips_places_asc(trip_id(fk), place_id(fk)) Since, many trips can ...
0
votes
1answer
41 views

Using Case in SQL

I want my query to fill in information where results are null. Particularly I want the PlanFirmSpecCode.SpecialCode to = the FinancialPlanner.LastName when the special code field is null. And when my ...
0
votes
2answers
43 views

Need help about giving relationships in database design

I am developing a simple blog application in which users can write posts and others can like, comment, share etc. i am facing difficulty in designing database. What I have tried is: user ...
0
votes
0answers
27 views

MySQL performance_schema not working properly?

I have MySQL 5.6.19 community server running on my Ubuntu 14.04. Lately I have been trying to monitor MySQL server using performance_schema. Previously I used to do this by running SHOW FULL ...
0
votes
0answers
34 views

Where statement involving isnull/case

Here is my query: [SuggestedRetailPrice] > 0 AND (ISNULL( CASE WHEN [AdEnd] < GETDATE() THEN [AdPrice] END, [BasePrice]) )/[SuggestedRetailPrice] > 0.8 ...
0
votes
1answer
60 views

Sum(Case When) Question

I'm trying to get the syntax correct on my query but I'm having issues. Currently my query will show the Household Total Value (HHValue) and then the NationalValue on one row, then the second row ...
0
votes
1answer
29 views

Populate a table with “WITH” clause [closed]

How to perform the following select query? with x (x, y, z) as ((2 5 6), (6,3,2)) select * from x I am not sure if this approach is possible. Not even sure if the syntax is correct. But I don't ...
0
votes
0answers
23 views

HSQLDB 1.8: Trying to have the result table contain two records in each row and be sorted

I'm really stuck doing this because each time I think I have a solution, HSQLDB v1.8 doesn't support it. I am forced to use this version at work, and believe me, I wish I could use a new DB, even v2.x ...
1
vote
1answer
54 views

SQL Pivot column

I'm trying to figure out how to create a From and To column based on ID.LocationID Column. I'm hoping with a suggestion this can be done (i can figure it out) without having to create sample tables ...
2
votes
1answer
86 views

Why am I getting cardinality issues when querying a single table

I have the following query: SELECT [iri].[RateItemKey], [iri].[RateItemType] FROM [prism72].[dbo].[ispRateItem] AS [iri] WHERE [iri].[Status] = 1 AND ( ...