sql

Find duplicate/repeated rows in hierarchical sql

I'm attempting to detect duplicated/repeated values within a hierarchical table. Consider the following (slightly contrived) example: SELECT * FROM emp START WITH mgr IN (SELECT empno FROM emp WHERE ename = 'JONES' UNION ALL SELECT empno FROM emp WHERE ename = 'JONES') CONNECT BY PRIOR empno = mg...

Delete a row at a certain line number in Postgres

I am building an app in which I need to delete a table row at a certain line number. I don't want to use or rely on an id, because if I delete a row, the following rows won't "shift down" -- line 8 today could be line 7 tomorrow, but line 8 will still have an id of 8. How can I write a postgres SQL that essentially does this: DELETE F...

SQL creating a column of alternating values based on a condition

Hi, I would like to create a query that returns rows in the following format: string name, int period, double value, string category where there are two sets of data which I want to have the same name and period, the value is arbitrary, and the category should be 1 or 2. The category data does not exist and needs to be 'created' within...

Differences between SQL Plus and "regular" SQL?

I'm new to the Oracle Platform (having primarily used MySQL, with a little Postgres and SQL Server as well). I recently discovered the following statment DESC TABLE_NAME; will only work in the SQL*Plus tool I use to test my queries. It will NOT work when I use PHP's standard functions to connect to the oracle database. I need to us...

.NET Data Provider that can Insert 300,000 Records Really Fast?

I am making an application that is able to display log files and search throught them, in C#. I need data provider that can insert 300,000 records really fast. Does anybody have any sugestions? I am currently using Microsoft Compact server 3.5 and that is going really slow. I tryed sqlite but it performed slow because I could not do bulk...

Comparing data in two (or more) ranges in the same field

I have a simple table as follows SQL> select * from test; ID STUFF ---------- ------------------------------------------------------------ 1 a 2 b 3 c 4 d 5 e 6 f 7 g 7 rows selected. I'd like to construct a query that returns something like this: STUFF A STU...

Database design: Store data from paper forms in database

Database design question for y'all. I have a form (like, the paper kind) that has several entry points for data. This form has changed, and is expected to change over years. It is being turned into a computer app, so that we can, among other things, quit wasting paper. (And minor things, like have all the data in one central store that c...

Optimisation techniques for sqlite database

I'm creating Android application that contains a large amount of data. It takes lot of time to access the data. What are optimization technique that I can use ? Are there any optimized queries? ...

Display whole data to the Admin

I have one database it contains some user information column including with is Admin column. My requirement is that the loggined user is an admin, then he has a right to see the first name and last name of the users that i stored in the database. If i use select clause, it shows only the loggined person's information. But i want to displ...

Is a JOIN faster than a WHERE ?

Suppose I have two tables that are linked (one has a foreign key to the other) : CREATE TABLE Document ( Id INT PRIMARY KEY, Name VARCHAR 255 ) CREATE TABLE DocumentStats ( Id INT PRIMARY KEY, DocumentId INT, -- this is a foreign key to table Document NbViews INT ) I know, this is not the smartest way of doing things, but t...

Help refactoring an SQL query

Dear Friends.. Below is my SQL Query which takes more than 10 minutes and still running.... select DISTINCT Auditdata.ID,ns.ProviderMaster_ID as CDRComment from Auditdata AuditData inner join AuditMaster am on am.ID=AuditData.AuditMaster_ID inner join HomeCircleMaster hcm on hcm.Ori_CircleMaster_ID=am.CircleMaster_ID ...

What is the execution sequence of Group By,Having and Where clause in SQL server?

Hi all, I am just confused with the execution sequence of sql query when we use GROUP BY..HAVING with WHERE clause. Which one get executed first?? Please help me. ...

sql reporting services problem with subreport in 3rd level group

i'm getting an error when trying to put a subreport inside a inside a 3rd level group of a table or list (it doesn't matter, same error) i have put a clean subreport withouth datasource without parameters, just a textbox when i put that subreport inside 1st or 2nd level group it's ok, when i put it inside a 3rd level group(or higher) i ...

Cross referencing sql tables php

Hi, I will try and explain this as best I can, any questions please ask: I have three tabels - tblOrderProducts tblOrders tblProducts tblOrders contains the order details but not the actual products that the customer has ordered, so I need to cross referrence the tables: VendorTxCode is a field in both tblOrders and tblOrderProduc...

Dlookup problem null value

I have a problem with the below dlookup fuction its result Null value txtAbsSunStore1.Value = DLookup("Store1", "tblAbsense", "TestId = " & lstResults.Column(1, 0) & " And Day = 'Sunday' And Empid = " & Me.txtEmpIdSearch.Value & " ") All the variable have value and the corresponding value is there in the table too ...

Linq to Sql Skip function problem?

Hello I have a problem with Skip function.. I code I have for fetching data is db_stamperDataContext context = new db_stamperDataContext(); //var modifier = (from m in context.Modifiers // where m.Modifier1 == "Public" // select m).First(); //var item = from p in context.It...

T-Sql 2005 Adding hours to a datetime field with the result within working hours

I have two Datetime fields that I wish to add together. They are in the following format: '01/01/1900 00:00:00'. The main issue with this is that I want the calculation to only include working hours. The working day is between 08:30 and 17:30 and does not include weekends: Also if the first field starts out of the working day or is on ...

MySQL GROUP BY Problem

Hi all, I have a complex MySQL problem. SELECT * FROM banners, content_id_country, languages WHERE content_id_country.content_id = banners.id AND content_id_country.controller = 'banners' Gives me a long result back. The result is perfect, there is only one problem. Some rows are duplicates, so they have only one field c...

Loading data from SAS to Teradata - When is it ready?

When loading tables from SAS to Teradata, SAS loads the data (usually using the FASTLOAD facility) and then continues down the script. However, I often get critical errors because SAS says the data is loaded, but Teradata is still assembling the data within the table. So the data is in the database, but not ready to be used. I have yet...

Immediate Window while debugging Stored Procs in Visual Studio 2005

Debugging stored sproc can be menace, & I was not able to use the Immediate Window like the way I thought I would be. Is the immediate window available while debugging Stored Procs in VS 2005? Is there any other way I would be able to run queries on a Temporary Table which I am creating inside a Stored Proc ? As the scope of the Temp...