query

How to run a loop of queries in access?

Hi I have a database with a table which is full of conditions and error messages for checking another database. I want to run a loop such that each of these conditions is checked against all the tables in the second database and generae a report which gives the errors. Is this possible in ms access. For example, querycrit table id...

Hierarchical Queries in SQL Server 2005

Way back when I was working in an Oracle shop I took the CONNECT_BY for granted. Now I'm stuck working with SQL Server 2005 and have some nasty object hierarchies. Specifically, we have a self referencing table where all child records have a column with their parent's id. Currently we have a view that maps children to levels in the hi...

Rows in their own columns depending on their value

I have a select query that currently produces the following results: Description   Code   Price Product 1       A       5 Product 1       B       4 Product 1       C       2 Using the following query: SELECT DISTINCT np.Description, p.promotionalCode, p.Price FROM Price AS p INNER JOIN ...

Finding the difference in rows in query using sqlite

After a few hours of searching, I'm not getting anything that works with Sqlite. It's driving me nuts. I have an sqlite table that contains prices for various products. It's a snapshot table, so it contains the prices on 5 minute intervals. I would like to write a query that would return the difference in price from one row to the next ...

Help write a query: Confusion over order of operations of GROUP BY and ORDER BY

I have a table named Info of this schema: int objectId; int time; int x, y; There is a lot of redundant data in the system - that is, objectId is not UNIQUE. For each objectId there can be multiple entries of time, x, y. I want to retrieve a list of the latest position of each object. I started out with this query: SELECT * FROM Inf...

How do I write a mysql query that will read data from one table and write to another?

If this is possible, please provide a sample query or two so I can see how it would work. Both tables will be in the same database. Thanks! ...

Oracle PL/SQL Query Order By issue with Distinct

Does anyone know what is wrong with this query? SELECT DISTINCT c.CN as ClaimNumber, a.ItemDate as BillReceivedDate, c.DTN as DocTrackNumber FROM ItemData a, ItemDataPage b, KeyGroupData c WHERE a.ItemTypeNum in (112, 113, 116, 172, 189) AND a.ItemNum = b.ItemNum AND b.It...

Improve oracle query performance without indexing

What are some things I can do to improve query performance of an oracle query without creating indexes? Here is the query I'm trying to run faster: SELECT c.ClaimNumber, a.ItemDate, c.DTN, b.FilePath FROM items a, itempages b, keygroupdata c WHERE a.ItemType IN (112,115,189,241) AND a.ItemNum = b.ItemNum AND b.ItemNum = c.ItemNum ORDER...

What is the proper syntax for a cross-table SQL query?

Right now, I have SELECT gp_id FROM gp.keywords WHERE keyword_id = 15 AND (SELECT practice_link FROM gp.practices WHERE practice_link IS NOT NULL AND id = gp_id) This does not provide a syntax error, however for values where it should return row(s), it just returns 0 rows. What I'm trying to do is get the gp_id from gp...

Informix: how to get an id of the last inserted record

What's the most efficient way of getting the value of the SERIAL column after the INSERT statement? I.e. I am looking for a way to replicate @@IDENTITY or SCOPE_IDENTITY functionality of MS SQL ...

SQL Query Help - task ordering, grouping and status + date conditions problem

Hopefully I can do the problem justice, because it was too difficult to summarise it in the title! (suggestions are welcome in the comments) Right, so here's my table: Tasks task_id (number) job_id (number) to_do_by_date (date) task_name (varchar / text) status (number) completed_date (date) ...

Access 2007 VBA Query Shows Data in Query Analyzer But Not in VBA Coded Recordset

I have a function I've written that was initially supposed to take a string field and populate an excel spreadsheet with the values. Those values continually came up null. I started tracking it back to the recordset and found that despite the query being valid and running properly through the Access query analyzer the recordset was emp...

Is seven inner joins in a query too much?

I have a query that has 7 inner joins (because a lot of the information is distributed in other tables), a few coworkers have been surprised. I was wondering if they should be surprised or is having 7 inner joins normal? ...

What is a good design for an extensible query interface?

Our application exposes queries by way of web services, and what we've found is that our clients often want custom queries, either by way of further limiting the results returned by specifying additional criteria, or by asking for things that we don't already expose. Now, we can take the approach of creating new methods for each of thes...

Sql Server Dynamic Queries

Hi, I have a very simple question. I have 15 stored procedures that return data from a common table, then join that table with a specific table to retrieve inventory. Ex. Common: tblCommonSpecific: tblSpecific Is there i was i can pass the name "tblSpecific" into a single stored procedure as a variable, like this: SELECT .... FROM ...

query: cross product instead of join

I have two tables that I would like to join but I am getting an error from MySQL Table: books bookTagNum ShelfTagNum book1 1 book2 2 book3 2 Table: shelf shelfNum shelfTagNum 1 shelf1 2 shelf2 I want my results to be: bookTagNum ShelfTagNum shelfNum book1 shelf1 1 book2 shelf2 ...

How to Fix This MySQL Query So It Works?

I have the following query: UPDATE lessonstatus INNER JOIN user ON lessonstatus.user_id = user.user_id SET user_id = (SELECT user_id FROM user WHERE username = 'too_many_accounts') WHERE last_name = 'stupid' AND first_name = 'user' AND username != 'too_many_accounts' AND lessonstatus.lesson_id NOT IN (SELECT lesson_id FROM lessonstatus...

Sharepoint Lists - GroupBy?

Hello, I'm trying to get data from a Sharepoint list and put it into some Flex graphs. I can call the list data just fine using a CAML query, but I want to use a GroupBy to consolidate the rows by Teams. So, for example Team 1 may have 20 records, Team 2 may have 8 records, and Team 3 might have 25 records... Instead of showing 53 rec...

Finding Unique Table/Column Combinations Across SQL Databases

I have 4 databases with similar schema's, and I'm trying to create a query to return just the table, column pairs that exist ONLY in database 1 and do not exist in database 2, 3, or 4. Currently I can return the symmetric difference between database 1 and 2 via the following query... select table_name, column_name from ( select ta...

How to Write a Query to Merge Two Accounts and their Activity Logs into One?

We frequently have users that create multiple accounts and then end up storing the same lesson activity data more than once. Once they realize the error, then they contact us to merge the accounts into a single one that they can use. I've been beating myself to death trying to figure out how to write a query in MySQL that will merge th...