query

Querying Oracle with a pick list

I have an oracle database that I have read-only access (with no permission to create temporary tables). I have a pick list (in Excel) of 28000 IDs corresponding to 28000 rows in a table which has millions of records. How do I write a query to return the 28000 rows? I tried creating a table in access and performing a join through ODBC b...

Flex and Bison Associativity Problem

Using Flex and Bison, I have a grammar specification for a boolean query language, which supports logical "and", "or", and "not" operations, as well as nested subexpressions using "()". All was well until I noticed that queries like "A and B or C and D" which I'd like parsed as "(A & B) | (C & D)" was actually being interpreted as "A & ...

Total with select query

Hi, Consider the following data: Insurance_Comp | 1To30DaysAgeing | 31To60DaysAgeing | 61To90DaysAgeing | TotalVehicles ============================================================================= ABC | 30 | 5 | 20 | 55 XYZ | 10 | 35 | 5 | 50 I am calculating the number of vehicles aged for particular group after a stock# is assi...

Hi I need to write Insert Query in SQLite3 in iPhone

Hi need insert data in table if the record is not already exits Ex: IF NOT EXISTS (SELECT Id FROM table WHERE id=_Id) THEN INSERT INTO tbale(.....) This can be easily done using stored procedure in MySql. But I want to d same thing in SQLite by writing a single query statement. Pleas help ...

New to SQL, need help with query

Hello all; I have a database table of my own that I am trying to construct a query for that seems simple enough, but I feel like I am messing up somewhere because the results are not what they should be. I basically have a table that is like the following: Table: Data Columns: Row ID Profile Import ID Field ID...

Whats the difference between an in-memory table, temp table and a pivot table?

With regards to SQL and queries, whats the difference between an in-memory table, temp table and a pivot table? ...

Retrieve TOP X members of each group using SQL Server 2005

I've seen this question asked a couple of times, and I've written my own query, but it's quite slow, and I would be extremely grateful if someone could offer advice on how to speed it up. In a simplified scenario, I have the following two tables: Group - GroupID (primary key) Member - MemberID (primary key) - GroupID (foreign key) L...

Whats the best SQL Query to get Related Items?

I have a small site where I want to get Related Videos on basis of Tags... what could be the best MS SQL 2005 query to get related Videos on basis of Tags. If you can give LINQ query that would be awsome. Here is Database Schema: CREATE TABLE Videos (VideoID bigint not null , Title varchar(100) NULL, Tags varchar(MAX) NUL...

Python Implementation of RubyonRails UrlEncodedPairParser / Rack::Utils.parse_nested_query

Does anyone know of a python implementation of RubyonRails UrlEncodedPairParser or Rack::Utils.parse_nested_query? I think I remember seeing a version in one of the python frameworks (not django) but can't seem to find it? ...

SQLite query optimization (subquery and join) help

I have a table for a Statistical project. Structure is like this: CREATE TABLE NewStatHistory ( StatHistoryID uniqueidentifier PRIMARY KEY NOT NULL, DateEntered dateTime NOT NULL, DateApplies dateTime NOT NULL, WhoEnteredID uniqueIdentifier NOT NULL, PostingID uniqueIdentifier NULL, EnteredValue decimal(19,5) NO...

Efficient SQL 2000 Query for Selecting Preferred Candy

(I wish I could have come up with a more descriptive title... suggest one or edit this post if you can name the type of query I'm asking about) Database: SQL Server 2000 Sample Data (assume 500,000 rows): Name Candy PreferenceFactor Jim Chocolate 1.0 Brad Lemon Drop .9 Brad Chocolate .1 Chris Chocolate .5 Ch...

Opening a new query window in management studio with prepared "select * from" text

Hi I edited SQLFile.SQL as "select * from" in order to have a new template when I create a new query. but it seems that still I have a blank window.... what's problem ? ...

MySQL - Getting search results from table and referencing tables

Hey everyone, (Using MySQL and PHP) I have a search form that will allow my users to type in a string, and search that string on a particular criteria. My problem is that a user needs to be able to search for information that is "spread" across multiple tables. For example: -Table "users" contains fname, lname, role, username (PK) -...

Grouping result by date in mysql

This SQL statement SELECT `ip`, `when` FROM `metrics` WHERE `vidID` = '1' GROUP BY DATE('when') returns one result, even though multiple are present in the table with different dates. I've tried using DATE_FORMAT as well. Am I doing something stupid? When is a timestamp column with full timestamp, including hours, minutes and seconds...

Group sum from two tables according to date in MySQL

Hi, I have two different tables, lead and click. I would like to query MySQL to get the sum of the commissions generated by clicks and leads ordered by date. Lead id|date|commission Click id|date|commission (Both have other fields, but they aren't important for this question.) So if I had: Lead: 1|2009-06-01|400 2|2009-06-01|3...

MYSQL select statement - 5 results from each user

I'm trying to do a select statement and it works except that it's not limiting the number of results for each user (U.id) to 5. SELECT F.id,F.created,U.username,U.fullname,U.id,I.id,I.cached_image FROM favorites AS F INNER JOIN users AS U ON F.faver_profile_id = U.id INNER JOIN items AS I ON F.notice_id = I.id WHERE faver_profile_...

getting non-distinct results from a distinct mysql query

Right, another question on queries (there must be a syntax guide more helpful than mySQL's manual, surely?) I have this query (from another helpful answer on SO)... SELECT DATE_FORMAT(`when`, '%e_%c_%Y')date, COUNT(`ip`) AddressCount FROM `Metrics` WHERE `ID` = '1' GROUP BY DATE(`when`) I now want to do a similar query to get unique/...

using MIN on a datepart with Group BY not working, returns different dates

Hi there, Can anyone help with an aggregate function.. MIN. I have a car table that i want to return minimum sale price and minimum year on a tbale that has identical cars but different years and price ... Basically if i removed Registration (contains a YEAR) from the group by and select the query works but if i leave it in then i get...

Python SQL Select with possible NULL values

Hi, I'm new to python and have hit a problem with an SQL query I'm trying to perform. I am creating an SQL SELECT statement that is populated with values from an array as follows: ret = conn.execute('SELECT * FROM TestTable WHERE a = ? b = ? c = ?', *values) This works ok where I have real values in the values array. However in some...

Select data from a record collection type.

I have a stored proc in oracle 11g server that has an out variable of record. I cannot edit this procedure. I am creating a function that will call the procedure and return the information in the record set. I looked at the following question asked here: past question My Question is can I create a type of table for a record and query i...