sql

Do any parsers exist for the Oracle DML table_reference?

Or are there any oracle data dictionary to tell me which tables are being referenced in (materalised) views? I wish to find out what tables references are used in a DML. I prefer to use an oracle package as it can be self contained in the database. But other suggestions welcome. Open source very welcome. Here is the link to the synt...

What does this query mean?

I'm reading a book about SQL. In that book, I saw strange query below: SELECT * into mycustomer from customer WHERE 1=2 In this query, what is "WHERE 1=2" ? ...

Syncronize AD changes in SQL server

Our sysadmin renamed several of our AD groups that we are using in SQL server. The SQL login still has the old name. Is there a way to syncronize AD and our SQL logins? ...

how does a SQL query work?

How does a SQL query work? How does it get compiled? Is the from clause compiled first to see if the table exists? How does it actually retrieve data from the database? How and in what format are the tables stored in a database? I am using phpmyadmin, is there any way I can peek into the files where data is stored? I am using MySQL ...

Native SQL - How to set the schema and database names

Im using Native SQL from ABAP language. The query to get data is something like this SELECT COUNT(ROWID) FROM <SCHEMANAME>.<TABLENAME>;@<DATABASENAME> INTO :localvariable I want to somehow set the schemaname and database name as default so that i do not need to use them in the SELECTs later. Then i can only use the table name in the...

How to convert the time difference to hours(with 2 decimal place) in derby?

Hi, I am using timestampdiff in derby db to retrieve the time difference between 2 time: startdate, and enddate. e.g. startdate = 2010-02-23 02:59:52.045 enddate = 2010-02-23 03:45:39.898 select {fn timestampdiff(SQL_TSI_HOUR, startdate, enddate)} as diff I would like to know how can I get the time diff in hours, e.g. 0.25, etc? ...

Exclude results where two fields are not of certain values

I have two tables which have some transactional stuff stored in them. There will be many records per user_id in each table. Table1 and Table2 have a one-to-one relationship with each other. I want to pull records from both tables, but I want to exclude records which have certain values in both tables. I don't care if they both don't have...

need to read data from oracle database with many conditions

hi! i have 3 tables A,B and C. table A has column employee_name,id table B is the main table and has columns id,os version. table c has the columns id,package id and p_version. I want to query the count of employee_name where the id of table a and c are matched with id of table b(which is the main table). I should also get the names...

mysql subquery strangely slow

I have a query to select from another sub-query select. While the two queries look almost the same the second query (in this sample) runs much slower: SELECT user.id ,user.first_name -- user.* FROM user WHERE user.id IN (SELECT ref_id FROM education WHERE ref_type='user' ...

What's the difference between these LINQ queries ?

I use LINQ-SQL as my DAL, I then have a project called DB which acts as my BLL. Various applications then access the BLL to read / write data from the SQL Database. I have these methods in my BLL for one particular table: public IEnumerable<SystemSalesTaxList> Get_SystemSalesTaxList() { return from s in db.SystemSalesTa...

Multiple select statement in stored procedure

Hi, i have a stored procedure that has to retrieve data from multiple tables something like SELECT [AppointmentId] ,[ContactId] ,[Date] ,[BookedBy] ,[Details] ,[Status] ,[Time] ,[Type] ,[JobId] ,[AppointmentFor] ,(Select PersonFirstName from Person where Person_Id = [AppointmentFor]) As UserFirstName ,(Select Per...

Qlikview joins that doesn't join on all matching column names

Hi! I'm new to Qlikview and looking for some answers regarding scripting. How can I create Qlickview joins that just join on a specific column (and not all that are having a matching name)? Let's say that I'm having the following tables: Employee Id | Person | DepartmentID | Flags 1000 , Bob , 2001 ...

Please help me design a sql query for this problem

For a particular name i want to fetch other names who have lived in three or more cities lived by this person. ...

sql: Group by x,y,z; return grouped by x,y with lowest f(z)

This is for http://cssfingerprint.com I collect timing stats about how fast the different methods I use perform on different browsers, etc., so that I can optimize the scraping speed. Separately, I have a report about what each method returns for a handful of URLs with known-correct values, so that I can tell which methods are bogus on ...

Displaying rows in multiple columns

Not sure if this is doable using sql alone or not, but here is the problem. I have a weird requirement that data needs to be displayed in columns so users can compare data quickly! Here is what the result set looks like right now CustomerID Company Active 001 ATT Y 002 ATT N 003 ATT Y ...

Django query: Count and Group BY

I have a query that I'm trying to figure the "django" way of doing it: I want to take the last 100 calls from Call. Which is easy: calls = Call.objects.all().order_by('-call_time')[:100] However the next part I can't find the way to do it via django's ORM. I want to get a list of the call_types and the number of calls each one has WITH...

Does any SQL frontend display sub-datasheets?

I'm looking for an SQL client app that can display subdatasheets like the following: Do you know of any? ...

Recovering transaction log from corrupt SQL database

We have a database that is backed up weekly in simple mode. Yesterday, we had a crc error corrupt the mdf file and we were unable to save it. I restored the backup from last week, but now we have a gap from the time of the backup to the time of the restore. Since I have the ldf file from that database, is there any way to "replay" tha...

how can write this stored procedure, so that would not hide the error

At the moment I write stored procedures this way: create proc doStuff @amount int as begin try begin tran ... if something begin select 'not_good' rollback return end if someelse begin select 'some_other_thing' rollback return end --do the stuff ... commit end try begin catch if @@trancount > 0 rollback select 'error' end catch th...

Tagging and how to test a tag exists

I plan to store tags (like the ones on Stackoverflow) using the Toxi scheme Tags are stored in a separate table. create table tags ( tagSeq int unsigned, name varchar(255), PRIMARY KEY (tagSeq), UNIQUE INDEX (name) ); In the add a tag usecase, multiple concurrent threads will be attempting to check if a particular tag exis...