DO NOT USE this for questions targeting Microsoft SQL Server, use the tag sql-server instead. "SQL" is an acronym for "Structured Query Language", it is used in relational database management systems (RDBMS) to query, update, delete, and insert data as well as modify the structure of the database. ...

learn more… | top users | synonyms (1)

0
votes
0answers
12 views

How to retrieve all data from table if column value providing null value?

How to write a query: If country = ' ' I need to display all data in table. If country='algeria', it will display the particular data. I need both queries in a single query. I am getting result, ...
0
votes
2answers
28 views

SQL query to group different data seperately in the same table

I would like to know how to construct an SQL query to group different subsets of data in the same table to get the count of each item in a horizontal result set. For example, the query against the ...
-2
votes
0answers
26 views

How do I join these queries into one query? [on hold]

I have these below queries. How do I join these 3 queries into a single query? 1st query: SELECT TOP(1) @tmpOnlineCat = ac.AlertCatID FROM alert.AlertCategory ac WHERE ac.FkAlertID = 2 AND ...
1
vote
2answers
11 views

Need to make MySQL's LOAD DATA LOCAL INFILE load large data faster

I need to load 4 million rows of data into a MySQL InnoDB table using LOAD DATA INFILE and would like to know if there are server configuration options I can tweak to get faster load. It took me 15 ...
0
votes
1answer
12 views

ORA-01722 Error when running stored procedure

I am trying to run a stored procedure however when I run it with an a valid Number it gives me an ORA-01722 error. I checked to make sure that the columns in the where clause where the parameter is ...
0
votes
1answer
12 views

SQL Server 2008 R2 Replication not working - my 1st try

I am having difficulties when I attempt my first shot at SQL Server 2008 R2 Replication. Looks like I have login issues. How do you modify settings without having to start a new plan again? Please be ...
1
vote
1answer
16 views

making a where clause optional in a sql statement

Here is my current query: `SELECT `performers`.`hash`, `performers`.`alias`, `performers`.`date_updated`, `performers`.`status`, IF(`performers`.`status` = 'active', 'deleted','active') AS ...
1
vote
0answers
12 views

Explain unexpected result in MATCH () AGAINST ()

I have a database with a fulltext column name. I made a query SELECT name, MATCH (name) AGAINST ('breaking bad') AS score FROM files WHERE MATCH (name) AGAINST ('breaking bad'); So that I can see ...
0
votes
2answers
28 views

Whats SQL Server NVARCHAR(max) equivalent in MySQL?

Using SQL Server you just have to give the "MAX" parameter to the length of a text data type, but in MySQL there's no such a thing. According to Ispirer: "n" is the maximum number of characters, ...
0
votes
0answers
24 views

Why is the transaction log file not truncated though its simple recovery model? [duplicate]

My database is simple recovery model and when I view the free space in log file it shows 99%. Why doesn't my log file truncate the committed data automatically to free space in ldf file? When I shrink ...
1
vote
1answer
43 views

How do relations work in NOSQL? [on hold]

I was using SQL in all my previous application and to understand the Parse.com db storage, I wanted to know NOSQL. I tried searching the differences between SQL and NOSQL for past 2 days & I ...
-6
votes
0answers
23 views

what the wrong in this stetment [on hold]

Dim sqlQRY As String = " Select invqu FROM invodet WHERE invsun = '" & DataGridView1.Item(i, j).ToString & "' AND invon = " & Val(TextBox1.Text) & ""
-2
votes
0answers
12 views

This query returning different result sets [on hold]

Hi is have this query (SELECT DISTINCT CONCAT (MONTH(`Date`),'-',YEAR(`Date`)) from wp_result_plugin WHERE Bet=$Bet AND month(`Date`) = EXTRACT(month FROM (NOW())) ORDER BY MONTH(`Date`) ASC LIMIT ...
-2
votes
0answers
14 views

Calculate percentage of a column group by 2 columns in pivot table format using oracle 11g sql [on hold]

I would like to request help displaying count of a column and respective percentage of a column as in pivot table. I tried several options of which I yielded 18 rows when used kind of select first ...
2
votes
1answer
36 views

Can This Update Query Be Made Faster?

update line_items set product_id = dups.latest_product_id from line_items as li join products p on li.product_id = p.id join vendors v on p.vendor_id = v.id join vendorgroups vg on ...
0
votes
1answer
22 views

Error: Incorrect usage of UNION and ORDER BY

I have this query: SELECT DISTINCT CONCAT (MONTH(`Date`),'-',YEAR(`Date`)) from wp_result_plugin WHERE Bet=2 AND month(`Date`) = EXTRACT(month FROM (NOW())) ORDER BY MONTH(`Date`) ASC UNION ...
0
votes
0answers
10 views

How to Extract suffix from the table column names [on hold]

I have 2 tables , 1 contains answers and columns are A1, A2, A3 so 3 in A3 means this is answer to the question 3. tblAnswers Personid A1 A2 A3 =============================== ...
-1
votes
0answers
21 views

Add one column from another table [on hold]

I have query which works fine, but I wanted to Add one column from another table. Here is my query:- select Id,username,email,usertype,active,(CASE WHEN usertype='1' THEN 'Admin' WHEN usertype='0' ...
0
votes
0answers
31 views

How to extract common subqueries to simplify? [on hold]

I have a query like this: select S.ID, S.name student as S where not exists ( (select course_id from course where department_name = 'Biology' ) except (select course_id from S where ...
0
votes
1answer
33 views

Why people often said nosql has better write performance than sql? [on hold]

I have been hearing these comments all around the internet. But I cannot see a good justification for it. Agree that nosql use de-normalized scheme to store data, which does not require join (for ...
0
votes
0answers
48 views

sp_WhoIsActive is not displaying results

I'm trying to use the sp_WhoIsActive stored procedure that I've downloaded from here: http://sqlblog.com/files/folders/release/tags/who+is+active/default.aspx I'm running the procedure without ...
2
votes
1answer
37 views

Can't seem to understand why STUFF isn't working

I've got two tables that store questions and possible answers. The questions table can have multiple possible answers to it. I want to display the possible answers it can have per question.. For ...
3
votes
1answer
61 views

Combine multiple queries into 1 query

I have a message table in Postgres 9.4 that contains a words field of array type, with random words of a message. Currently I have millions of messages: \d messages Table ...
-1
votes
0answers
29 views

MySQL - Combining multiple rows as one in one table [duplicate]

I have one table employeeId | attribute | value 1 name John Doe 1 email john@example.com 1 age 28 2 name Jane Doe 2 ...
0
votes
1answer
22 views

How connect by is really working? How is it multiplying rows?

I know (on high abstract level) how hierarchies in Oracle works, but this one I do not understand. When issued following query: select rownum-1 as num from dual I've got one row as result. The ...
0
votes
1answer
15 views

Setting Key Constraints using a Diagram

I been using SSMS for diagramming my databases and I got used to create the key constraints with this tool. Now I started thinking, while going through related chapter of a book, "...maybe this is not ...
1
vote
1answer
15 views

Error when restoring SQL Server 2008 R2 backup on 2012

I am trying to restore a .bak file (backup taken on SQL Server 2008 R2, compatibility level 100). I am restoring the backup on SQL Server 2012 edition. I get the below error. Unfortunately the ...
1
vote
0answers
23 views

Best practices to segment people and attributes for advertising database

we have a database where we store people some attributes per person in the following tables: people (id, name, email, phone) people_attributes (id, person_id, attribute_name, attribute_value) ...
0
votes
0answers
46 views

Why are transactions long running?

My stored procedure has a transaction blog. I pick up a record from a database and process it in that transaction block. I noticed that my transaction log has grown in gigabytes. But my transaction ...
-2
votes
1answer
33 views

Generate create table DDL from any arbitrary select query? [on hold]

Is there a way, given any arbitrary select query like: select myfavoritenum, myfavoritetxt from tablewithmanycolumns and magically receive a create table statement: create table justmyfavorites ( ...
0
votes
1answer
28 views

Query calculating AVG per minute GROUP BY timestamp

I'm trying to query the average for each minute, so I can generate graph per 5, 15, 30 minutes. Here is my table, date stored in MySQL DateTime data type field. timestamp vif_2_rx ...
0
votes
2answers
77 views

How can I replace the following query with ISNULL function in SQL?

I have the following query. For performance optimization reasons I have been asked to replace the logic with ISNULL function in SQL. How can I achieve this? please advice. SELECT ...
0
votes
1answer
23 views

Insert sum of the row data of each record into separate column in postgreSQL?

I have a table id name class social science math Total 2 Max Three 85 56 85 3 Arnold Three 55 40 75 4 Krish Four 60 50 70 ...
0
votes
0answers
50 views

How can I replace the cursor in the below query?

I have this below query which calls a stored procedure that takes only 1 item's attributes at a time. But because of performance problems we are required to remove the cursor. How can I replace the ...
1
vote
1answer
45 views

Why is my transaction file growing when db is in simple mode and there are no waiting transactions

I noticed that my database log file has reached 160GBs. My database is in simple recovery mode and I used the following query to see if there are any waiting transactions. SELECT ...
0
votes
1answer
29 views

Insert date values in a created table

I have created a table using the below query CREATE TABLE job_history ( EMPLOYEE_ID decimal(6,0) NOT NULL, START_DATE date NOT NULL, END_DATE date NOT NULL, JOB_ID varchar(10) NOT NULL, ...
0
votes
1answer
22 views

How to segment account info and profile info?

I am putting a rough SQL database design together and have gotten stuck on how to segment information about the users. (Note before I get into anything, stored passwords are salted and hashed, I just ...
1
vote
1answer
18 views

Formatting SQL Source Code in SSMS [closed]

There are several source code formatters for SQL in SSMS. I have tried a couple and found that are not configurable in terms of what formatting they do (e.g. indenting). Does anyone know of one ...
0
votes
0answers
6 views

Macro to search list JDE ERP

I have a list of Part numbers in a txt file. I need to get the matching Inventory number for each from our JDE database. Is it possible to build a macro in I-Series to search a JDE database for ...
1
vote
1answer
30 views

Call function where argument is a (sub)select statement

My function takes an int4 as argument and returns a table: SELECT * FROM test_function(545421); -- works fine SELECT * FROM test_function(SELECT customerid FROM tableX ...
0
votes
1answer
43 views

SQL Server Deadlock on delete

I have a query like this: with xx as ( SELECT [FilePath], ROW_NUMBER() over (partition by [FilePath] order by [FilePath]) as RowNumber FROM [dbo].[foo] ...
0
votes
1answer
18 views

Can combine five mysql statements into just one statement?

Can I combine all the five statements into just one statement? update mytable set myfield1 = replace(myfield1, '…' ,'-') ; update mytable set myfield1 = replace(myfield1, '‖' ,'|') ; update mytable ...
0
votes
0answers
13 views

Query JDE ERP Excel

I have a spreadsheet with a list of values, each matching to a particular part. I need to get a matching inventory number for each. My company uses JDE as an ERP. Is there anyway to use Excel (or ...
-2
votes
1answer
27 views

conversion failed when converting the varchar value 'JENNIFER FALCONER

I am trying to compare a status of an order. For example, placed, despatched, Invoiced etc from two table one is 'order' and another 'customer' ... while executing this simple join query(shown below) ...
0
votes
1answer
25 views

Select Multiple distinct with Order By Date Clause [closed]

I have a MS-Access database tabel with follwing structure and Data : Now i want all the columns in my result with following conditions : TicketNo should not be repeated in result Result should ...
-1
votes
0answers
22 views

How to check if name has multiplr id's and count it as 1 [closed]

in sql query, how can i check if a name has multiple id's and if it has, it will be counted as 1. For example i have 2 names and it has 2 ids, and then when i group it how can it be counted as 2 only ...
0
votes
2answers
26 views

Problem With update column in table [closed]

there is my problem. I have to update column "date_to" , but only for those users who havent set their last "date_to" to value '3000-12-31' . Table looks like this : ID date_from ...
1
vote
1answer
46 views

What difference between these 2 SQL styles?

If I have a simple table named: conn_log in my Redshift/Postgresql In the performance of view, what difference between these two commands ? select t1.wifi_name, (t2.sconn*100)::numeric/t1.ttconn ...
0
votes
1answer
54 views

How to remove duplicates and keep the one with the most additional information

I have a postgres table (postgres version 9.3.4) of addresses with duplicate addresses: Column | Type | Modifiers ...
0
votes
0answers
24 views

How do I create an after Trigger in sql for a price reduction?

So im trying to do this for a personal project of mine just as a hobby kind of thing. What i need help with is that im not sure how to put a SQL After trigger for something i want to try. What i have ...