The best n per group while returning content

I have looked at other answers but am having trouble applying the answers to my application. I have a query that returns something like the following: SELECT * FROM MYTABLE T; __________________________________________________________ | ID | AORB | .

SQL difference function between Name Column in 2 tables

I have 2 tables that contain a column for a name part, i.e. John Doe has a row for John and one for Doe. The 2 tables have different names in them. I need to take the name part from one table and calculate the DIFFERENCE score to the name part in the

why database links are bad for security

I heard database links are bad for organizations to use. Why is it bad for security?Where did you hear this? Database links, like any tool, have their uses and misuses. There is nothing inherently insecure about using a database link. But there are c

Join the sql windows table

I would like to insert a record into table RDV . The query of creation RDV Table: CREATE TABLE [dbo].[RDV] ( [idRdv] INT NOT NULL, [objet] NVARCHAR (50) NULL, [objectif] NVARCHAR (50) NULL, [DateRdv] DATETIME NULL, [commentaire] NVARCHAR (50) NULL, [

Split a string into multiple lines in Oracle 8i

I have a table consisting a list of names separated by comma. My goal is to separated them by rooms. Room | Name room1 | Anne,Amy room2 | Ben,Bryan My goal: Room | Name room1 | Anne room1 | Amy room2 | Ben room2 | Bryan I have read some solutions on

where to put% sign correctly in a query of type sql?

ResultSet data ="select (flavour) from doenets where flavour like = '"+name+"%' "); i think there is something wrong with this like query i tried replacing the position of % sign but didn't work can someone tell me where

Query a nested game table to exclude all marked subtrees

I am creating a nested set with left and right columns. There is a column called exclusion. What I want to do is select all rows in the nested set but if the exclusion column is true, remove all other rows whose left and right column values fit betwe

Optimize Oracle SELECT on a large dataset

I am new in Oracle (working on 11gR2). I have a table TABLE with something like ~10 millions records in it, and this pretty simple query : SELECT t.col1, t.col2, t.col3, t.col4, t.col5, t.col6, t.col7, t.col8, t.col9, t.col10 FROM TABLE t WHERE t.col

SQL select of the subquery

I have an issue selecting from a subquery with this small demo data for example: ID CLASS_ID PROP STATUS ROW SELECTED STEP 12345679 1312 0 21 3 07-FEB-14 1 12345679 1312 0 21 1 26-FEB-14 -1 I want to get all the information (each column), the sql bel

Oracle SQL update using regexp_replace

I have almost 2000 rows in a table ("Sensor", which has many more than 2000 rows) in which I need to update one column, the sensorname. Part of the replacement within the update is based on the contents of another table, deviceport. Deviceport i

DQL Doctrine larger-n-by-group

Here are 2 tables of my Symfony2 project : +-----------+ +----------------------------+ | EVENT | | PHOTO | +-----------+ +------+-----------+---------+ | id | | id | event_id | likes | +-----------+ +------+-----------+---------+ | 1 | | 1 | 1 | 90

Run a subquery in MySQL that returns multiple rows?

I am executing a query that obviously contains a subquery in MySQL. Let me just jump into the code: SELECT DATEDIFF(CURDATE(), (SELECT due FROM checkOut JOIN People ON checkOut.p_id = People.p_id WHERE CASE WHEN DATE_SUB(date_add(CURDATE(),INTERVAL 4

Extract the different records in two tables

I have two tables - table1 and table2. Both tables have the same columns. I want to extract the record differences - meaning extract records in table1 not in table2, and extract records in table2 not in table1. How I can do that by using SQL in Oracl

SQL - Extraction of a set of several tables, grouping, then sum

I need to extract data from the tables RawData and RawDataMeter and sum the 'Value' field for each unique MeterId for the last 10 minutes (relative to the TimeStamp). The RawData and RawDataMeter tables as joined via the RawDataId field using a INNER

Efficient way to delete multiple lines in sp with a call

The below query returns me two rows: SELECT DocList.DocListId, RegistrationDocList.RegistrationDocListId, Registration.RegistrationId FROM DocList INNER JOIN RegistrationDocList ON DocList.DocListId = RegistrationDocList.DocListId INNER JOIN Registra

SQL nesting on the high school test

We made this test on my school, and according to the test this is the right answer: SELECT names FROM COMPANY WHERE NOT EXISTS (SELECT kgmilk FROM COWS WHERE kgmilk < 1000 AND = Now my question is, can you actually do =

Invalid identifier in Oracle function

This is my SQL; select a.hesap_no, a.teklif_no1 || '/' || a.teklif_no2 as teklif, a.mus_k_isim as musteri, b.marka, c.sasi_no, c.sasi_durum, d.tas_mar, nvl(risk_sasi(a.teklif_no1, a.teklif_no2, c.urun_sira_no, c.sira_no), 0) as risk, nvl(mv_sasi(a.te

Correct the template for a database with a table for each user

Kinda stuck here... I have an application with lets say 5000 rows of data per user and was wondering if it was right or wrong to do it this way: On user account creation a new table is created (UserData_[UserID]) or should I just have 1 table for use

Do you put your static database data into source control? How?

I'm using SQL-Server 2008 with Visual Studio Database Edition. With this setup, keeping your schema in sync is very easy. Basically, there's a 'compare schema' tool that allow me to sync the schema of two databases and/or a database schema with a sou

VARBINARY field size in SQL Server 2005

I am trying to determine the size in bytes of the contents in a VARBINARY(MAX) field in SQL Server 2005, using SQL. As I doubt there is native support for this, could it be done using CLR integration? Any ideas would be greatly appreciated.Actually,

Accelerate sql JOIN

First of all, some background. We have an order processing system, where staff enter billing data about orders in an app that stores it in a sql server 2000 database. This database isn't the real billing system: it's just a holding location so that t