query

Help optimizing an Oracle query

I'll preface this question by stating that I'm using Oracle 10g Enterprise edition and I'm relatively new to Oracle. I've got a table with the following schema: ID integer (pk) -- unique index PERSON_ID integer (fk) -- b-tree index NAME_PART nvarchar -- b-tree index NAME_PART_ID integer (fk) -- bitmap index Th...

SQL flattening & dynamic query question

Firstly, I am not certain this is the best way to handle this AT ALL ... totally open to alternative solutions. Secondly, I feel like I'm missing the obvious ... but I'm still missing it so not to proud to ask! UPDATE: .NET 3.5 environment w/ SQL 2005, so things like dynamic linq possible, although I always tend to think of dynamic (bu...

oracle spool query

Hi All, I have written the sql by name cashload.txt on unix box and kept it on the following location on unix box: exit |sqlplus -s batch/password@SW_TEST @/soft/checkfree/AccurateBXG/scripts/cashload.txt In the cashload.txt the below code is written: spool /Detail/reports/inner/SW/Rep_OIbyAccount_$DATE_FILE.csv select accountnumber|...

Is it possible to do a "not equals" query in Dojo Grid?

I have a Dojo Grid that I'm filtering with a query that's set in a javascript function. function filter() { var grid = dojo.byId("gridNode"); grid.setQuery({fieldName:"Some Text"}); } What I'd really like to do, though, is filter it so that it shows all entries where the fieldName value is not empty. Does anyone know if there...

MySQL indexes - how many are enough?

I'm trying to fine-tune my MySQL server so i check my settings, analyzing slow-query log, simplify my queries if possible. Sometimes enough if i indexing correctly sometimes not. I've read somewhere (pls correct me if this is stupidity) more indexes than i needed make the same effect like i haven't any of them. How many indexes are eno...

Making a two column list from a database array

I am trying to pull data from a single column from my database but I would like to make it come out alphabetized and in two columns. I have tried floating the list but it ends up looking like this: A_____B C_____D E_____F I would like it to look like this: A_____D B_____E C_____F ...

SQL Query for count of records matching day in a date range?

I have a table with records that look like this: CREATE TABLE sample ( ix int unsigned auto_increment primary key, start_active datetime, last_active datetime ); I need to know how many records were active on each of the last 30 days. The days should also be sorted incrementing so they are returned oldest to newest. I'm using ...

Slow MySQL Query

Hi, I have a query in MySQL (used in a stored procedure) which searches by name and another field. When I use different combinations of these search parameters, I get quick results (between 1 and 2s) but with some particular values, I get a query which takes 9s to return results on the production website. The following is what I got out...

Query relating positon of the dropdown menu withrespect to the size of the browser

Hi , i m usin a vertical deopdown menu for my website .i had set its top and left attrtibutes in pixel to fix its position according to its parent elements postion.but when i reduce the size of the browser the dropdown menu remains at the same positon where it was when the browser was at its full size.can u helpme with that. if posible p...

Google AppEngine Query Order

How can I order the results of Query using more than 1 property? For example, I want to order my Query results by 'lastname' and order by 'firstname' in each group of 'lastname'. ...

Select top one from left outer join

Guys, I have a query where basically select the latest browser that our user used. here is our (simplified) table structure HITS_TABLE ---------- USERID BROWSER HITSDATE USER_TABLE ---------- USERID USERNAME and here is how I query the latest browser that our user used SELECT U.*, H.BROWSER FROM USER_TABLE U CROSS APPLY (SELEC...

Best tool for assisting writing complex SQL-queries?

Hello everyone, I often find myself spending a lot of time figuring out why certain SUM()-aggregates sum up wrongly in SQL-queries. This problem often occurs if I do not take care when adding a JOIN, resulting in duplicate values being summed up etc. If I work with a big query with lots of JOINs, nested subqueries, GROUP BYs etc. things...

T-SQL query to flag repeat records

I have a table that will have 500,000+ records. Each record has a LineNumber field which is not unique and not part of the primary key. Each record has a CreatedOn field. I need to update all 500,000+ records to identify repeat records. A repeat records is defined by a record that has the same LineNumber within the last seven days of i...

SQL UPDATE Query

I have One main table( Say main) and another Temp Table( say copy). What I am trying to do is averages and Standard Deviation of each Stored proc( there are bunch of them with different version number as suffix and they all has to be treated same) from main table and update Temp table with averages and standard deviation for each day. Fo...

PHP + MySQL problems :(

Hello, I am havin trouble with this code: if ($_GET['offline']) {$extranet = $_GET['offline'];} else {$extranet = $online;} $sql = mysqli_query($db,"UPDATE tbl_system SET value = '$extranet' WHERE property = 'extranet'"); echo $_GET['offline']; echo $extranet; echo $online; In the database, the value of the field where the property =...

Sql distinct selective row after a join question.

Let's say i have 2 tables Customer and Books. Table Books can have multiple rows that pertain to a row in Customer. Ex: customer John Doe has an id of 1000. Table Books has 2 rows with a member_id column with 1000 (John Doe). These 2 rows are identical EXCEPT one of the fields (book title) is empty. The other row has a value for a tit...

Grouping Consecutive "Wins" in a Row

Given rows: symbol_id profit date 1 100 2009-08-18 01:01:00 1 100 2009-08-18 01:01:01 2 80 2009-08-18 01:01:02 2 -10 2009-08-18 01:01:03 1 156 2009-08-18 01:01:04 2 98 2009-08-18 01:01:05 1 -56 2009-08-18 01:01:06 1 18 2009-08-18 01:01:07 3 ...

Mysql Like Syntax

Hi all, Quick question: How do I mysqli_escape_string a variable enclosed in a like clause? "SELECT * FROM table WHERE name LIKE '%". %s . "%'" or "SELECT * FROM table WHERE name like '%"."%s"."%'" don't work. Thanks! ...

Android quotes within an sql query string

I want to perform a query like the following: uvalue = EditText( some user value ); p_query = "select * from mytable where name_field = '" + uvalue + "'" ; mDb.rawQuery( p_query, null ); if the user enters a single quote in their input it crashes. If you change it to: p_query = "select * from mytable where name_field = \"" + uvalu...

what is more costly, 2 updates, or a delete and an insert?

For a certain piece of business logic, a sequence could be either two separate updates, or a delete followed by an insert. Basically, the update would nullify a column so I can make it seem like a delete. I am not concerned with losing rows (so a soft delete is not necessary): what is the more efficient approach? ...