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)

1
vote
2answers
80 views

How to know how long my server is started

I am working with postgresql-9.4 and for support and monitoring tasks I need to know how long my server is started? Is there any function or way to know this? Is there an sql way to know it? I ...
1
vote
1answer
29 views

PostgreSQL - Minimum number of rows per group

The following is my query: SELECT * FROM ( SELECT f.max, f.min, p.user_id, p.id, p.title, p.rating, RANK() OVER ( PARTITION BY p.user_id ORDER BY p.rating DESC, p.id DESC ...
0
votes
0answers
22 views

not a GROUP BY expression

I am not getting answer of this query SELECT DISTINCT HPD_Service_Type.owner_support_company,HPD_Service_Type.owner_support_organization, HPD_Service_Type.Service_Type, ...
0
votes
0answers
29 views

How to break down a sql select query into smaller chunks? [on hold]

I'm querying my SQL Server database from C# and the resulting dataset throws a MaxReceivedMessageSize exceeded exception. My MaxReceivedMessageSize size is set to size 40960000, and I'd like to keep ...
-1
votes
0answers
14 views

Trying to match transactions from two tables and list all unmatched rows

I'm having two tables of transactions and there are couple same transactions in both tables (same trade date, same quantity, same amount, same index). I'm having problems while two trades have same ...
0
votes
1answer
21 views

Get list of students having actions in Oracle

I have a table of student actions (id, student_id, type, and quarter). I need to get a list of all the students, along w/ a flag of whether they had a particular action in the current quarter, and the ...
0
votes
0answers
23 views

Help with existing database normalization [on hold]

For a project I have to normalize an excising database. I've no idea how I'm supposed to do this. I have no experience at all in database normalization. I now got a document with all fields, from ...
2
votes
1answer
24 views

Is there any database with versioning (column based) built in?

I'm wondering if there is a database (SQL or NOSQL) which provides versioning for for the records ( if the column/field/property is enabled for versioning). I'm developing an authentication software ...
4
votes
6answers
1k views

How to find the nth highest salary in SQL?

I have found a query to find the nth highest salary from Employee table , but i don't understand the logic of (N-1)? EmpID Salary 1 90000 2 80000 3 54000 4 ...
2
votes
1answer
34 views

Select Column value based on two values in another column

I am using the below table: 1 0051ML66220600132482 06:00:00 06:00:00 1538 100 0 1 2 0051ML66220600132482 06:00:00 06:00:00 1540 200 0 0 3 ...
-3
votes
0answers
17 views

Get column name in sql table according to particular value [on hold]

Table name is currentreport and in table i have columns (id,challan1,challan2,challan3) and value is inserting in the table now i want to know the name of column in which i insert the chalan no. for ...
2
votes
1answer
30 views

Display multiple IP address values for one system in a single row

I cannot for the life of me get the systems with multiple IPs to display under one row. Below is the current SQL statement I have. systems with more than one IP show up as duplicated on the report. ...
0
votes
1answer
45 views

How to add a column from another table?

I'm starting to using SQL statements in my Oracle database XE (tables and relations made by me) and I'm having a hard time to understand how can I put a column from another table. The example in ...
2
votes
2answers
54 views

String that contains letters representing a negative number

I would like for every string that has a letter on the end make it a negative value. <field> = '00000000014545p';--Varchar(15) <field> = '00000000012645x';--Varchar(15) <field> = ...
1
vote
2answers
61 views

Normalization of library book table with multiple authors

I have a database structure with two tables: The first one is called Author, has two columns (AuthID, AuthName) and its Primary Key is (PK_AuthID). The second one is called Book and has three ...
0
votes
2answers
83 views

How to this query? [on hold]

First of all, I know what I am about to show you is a completely DB mess but I just got it like this. Tables : Authors manufacturers_id manufacturers_name 1 Name1 2 ...
0
votes
0answers
32 views

How to retrieve data from database related to the authenticated user (after login) [on hold]

I have an authentication form in my jquery mobile app and I wanna be able to authenticate users using a wcf webservice that'll connect to my postgresql database and check their credentials. Now my ...
-1
votes
0answers
49 views

SELECT FROM OTHER TABLE WITH TWO SAME COLUMNS [on hold]

I have problemm with sql SELECT Emp Table | ID_E | NAME | ------------- | 1 | JAMES| Countries Table | ID_E | COUNTRY | ---------------- | 1 | USA | | 1 | UK | select p.id, ...
1
vote
1answer
98 views

Improve SQL Performance with LIKE '%ABC%' QUERY

I know that using a LIKE '%ABC%' query will not use indexes and there is little that can be changed to the query to improve this, however what can do to make execution quicker? At this stage we ...
4
votes
1answer
31 views

Does NTILE work over floating point numbers?

I am trying to use NTILE on my data using a float data type in my PARTITION BY clause. Please excuse the contrived example, but I think the best way to illustrate my question and confusion is through ...
1
vote
1answer
57 views

Question about the UNION operator and its implicit data type conversions

Is there a limit to the number of UNION operators to combine query results? I have an odd situation where I have a table called TransmittalSheet TS that have a double (1 to Many) relationships with ...
0
votes
0answers
17 views

How to avoid delimiter character in BCP export?

In my project, I need to use SQL 2008 BCP tool to export the result of a stored procedure into a fixed column width file. I used different approaches, but still couldn't get expected result. Things I ...
1
vote
1answer
27 views

What does: SET @Variable1 = (Select field1 From INSERTED) mean?

I'm trying to understand an existing Trigger on one of my tables (DocumentDistribution), that it seems is the bridge table between DocumentInfo and DocumentSource tables. I don’t understand how this ...
-6
votes
1answer
51 views

String or binary data would be truncated [closed]

I am sure this has been dealt with,but not able to find exact search on it.My problem goes like this my table structure: i am trying to enter below query insert into test1 select ...
0
votes
0answers
22 views

Query to Find Cluster Nodes for an Instance

I need a way, using T-SQL, to find the nodes available to a SQL instance. I have 3 nodes in a cluster running several instances of SQL Server, each instance is 2012 Standard and so can only be ...
1
vote
0answers
18 views

creating deadlock for distributed database in mysql-(Testing purpose)

I need to create a deadlock for distributed database in MySQL for testing purpose with a simple sql query(without front end), can anyone good with MySQL query help me out in this with sample query. ...
-1
votes
2answers
67 views

When there is a composite index and those columns are in query, does it use index seek? [closed]

I have a table staff having columns, name, year,month and date. I have a composite index on year,month and date. If I have a query like below, will it use index seek scan? select * from staff where ...
0
votes
0answers
8 views

SQL Query to compare (HL7) value at certain position in string based on delimiters (not position)

This is complicated by the fact that I don't know what DBMS the backend uses. I know it's Cache, but I don't seem to be able to do anything but the most basic commands. I cannot seem to SET or ...
2
votes
1answer
46 views

Regular expression in a SQL case statement

I have records formatted as such: CBS405/505 Fourth Week(Wtr Qtr) BR 404-504-604 Fifth Week(Fall Qtr) AP490-QB-09 Weekly Sessions(Spr Qtr) APR501 Fourth Week(Wtr Qtr) MP 300 Fourth Week(Wtr Qtr) ...
0
votes
1answer
19 views

Using If /then statements in SQL server computed column specification

I have two fields in a SQL Server database called "Species" and "Species _other" that stem from a front end data collection software dropdown values. I am trying to use a computed column using an ...
-1
votes
2answers
32 views

How to use aggregate function and group by with inner join? (Postgres 9.3) [closed]

I would like to select "extra" payments made in association with normal appointments for a one week period and SUM them up by contractor when calculating payroll. Here's what I attempted: SELECT ...
1
vote
1answer
39 views

Is there a performance hit for querying two different databases?

I have two tables, A and B, which are located in different databases on the same MySQL server. I would like to create a derived table C from tables A and B, as an inner join between the two tables. ...
0
votes
0answers
21 views

concept of foeign key from composite primary key in sql server 2012 [closed]

Suppose i have 2 tables. Table 1 say tbl1 has composite primary key. Table 2 say tbl2 has foreign key, that has one of the primary keys of table 1. Can anyone provide a query on how to ...
0
votes
0answers
18 views

Sharepoint Database extraction [closed]

Had Sharepoint running on SBS2003, server completely failed. I was able to use ubuntu live to boot server and pull data out of the RAID drives. I copied the MSSQL$SHAREPOINT folder over to a USB ...
-1
votes
0answers
24 views

Generating new empty values while retrieving data from a database [closed]

I have a Pettycash table Like this: PettycashId LedgerName OppositeLedgerName amount While I retrieving data like this: Select PettycashId,Ledgername,OppositeLedgername,Amount from Pettycash ...
1
vote
0answers
62 views

Getting count of visits for multiple different outlets

I'm trying to get the distinct count of id that visited different outlets. I have more than 50 outlets so I don't think I can use the IN operator. CREATE TABLE transact ( year int NOT NULL, card_id ...
1
vote
1answer
23 views

Shortcut for deleting a line of SQL

Is there a shortcut to delete your current line of SQL without highlighting the full line? I want to delete the line that my cursor is on without selecting the whole line. So in visual studio CTRL + ...
0
votes
1answer
15 views

Switching a partition on a table with one to many relation

There is two main tables in database (SQL Server 2014) table1: ---------------------------------------------- id name datetime image table2: -------------------------------- ...
1
vote
0answers
28 views

How do I cast a varchar to Bigint in DB2

I have a field which is varchar(25) and I need to create a join between that field and a field that is a bigint So I guess I need to convert the field into bigint aswell but it's giving me some ...
1
vote
1answer
31 views

Speed up procedure

I was wondering if this procedure can be executed faster. There are indexes on the joins and where's. Depeding on the size of product_id_CSV it takes approx. 2.5 sec. CREATE ...
2
votes
1answer
78 views

Query looks optimal but logical reads is huge

I run the following (really simple) query in SQL Server: SELECT MAX(PK_Field1) FROM MainTable kh WHERE kh.PK_Field1 >= '2014-12-01T00:00:00' AND kh.PK_Field2 = 1572 AND ...
2
votes
1answer
53 views

DB2 CASE statement faster with parentheses around entire WHEN

Trying to optimize slow queries, someone on my team come across this. Having this in our stored proc: CASE WHEN MYCOL BETWEEN @STARTNUM AND @ENDNUM AND RECTYPE = 'RO' THEN 1 ELSE 0 ...
1
vote
2answers
53 views

Running a T-SQL job under another user

I cant find my proxy user to "Run as" that user !? I am confused which kind of proxy user is appropriate to run a job with a simple T-SQL command. (I have created a credential and proxy but cant find ...
0
votes
1answer
30 views

Oracle SQL Complications With Multiple Triggers

Hey all so I am creating a DB that is used going to be used for managing utilities of a system. My DB has 3 tables: Users, Utilites, and Files (leaving Files table out because question shouldn't ...
1
vote
2answers
26 views

Can I select data inserted in the same uncommited transaction?

Maybe this is a dumb beginner question, but I cannot find an answer anywhere. Everywhere I read about the Transaction Isolation which solves the visibility of data within the concurrent transactions. ...
0
votes
1answer
27 views

Inner join on array column in Postgres

In Postgres 9.4, I'm trying to pull the names of all columns that are involved in a UNIQUE constraint for a given table in Postgres. It looks like the names of such columns are contained in ...
0
votes
2answers
43 views

inner join select - group by?

I have 2 tables (Oracle database): ANEXA2A_TABEL1: id fk_id_anexa pet1 pet2 alt1 alt2 1 123 10 1 20 2 2 321 11 2 10 3 ...
0
votes
1answer
76 views

Select only rows that equal x but not x and y?

I'm having quite the challenge with selecting hierarchical data in mysql although I feel the schema should be optimized for it since it's based on the wordpress database model. I've got 4 tables... ...
0
votes
0answers
25 views

Designing multi-table notes

I have several tables (Providers, Items, Users) representing items that my users can comment on. In the OO mindset, if the above tables were classes, they would each be a subclass of Commentable, ...
0
votes
0answers
38 views

Database deploy automation

In my company the developers use migrations for the schema changes in the database server and for install new databases too. More precisely they use Active Record (Ruby version). They have a project ...