query

Free SQL Query generator tool for oracle database?

Do you use any free tool to generate query for oracle database. Tool that autocomplete and suggests the table names and column names. ...

Using an IN clause with MySQL with stated values

I'm trying to write a query that updates rows in a table if a certain column has a value in a list I'm providing: UPDATE MY_TABLE SET COL1 = 'xyz' WHERE COL2 IN ('x', 'y', 'z'); I'm getting a syntax error, but I know that this should be possible. It's essentially a single command to execute the following 3 commands: UPDATE MY_TABLE S...

LINQ where Clause doubt

I have tried one where clause in Linq to get details about Users those who are Active and AllowLogin is also true. So how can I compare the table values (both are boolean values) with true or false? ...

SQL 2005 Query Help

I have table with 50 entries (users with such details like Name Surname Location etc) I want to create a query that give me users from row 1 to row 10. Then another query that give me users from 11 to 20 and so on. Is there any way how to do that? Thanks ...

How to change the data type of a column with query?

I have a column which has a datatype : datetime. But now i want to convert it to datatype varchar. Can i alter the datatype without droppping the column? If yes, then please explain how? ...

In Access 2003, how can I call a custom VB function from a query?

Is is possible to call a custom VB function, saved in the same Access Db, from a query written in that db, and if so, how? ...

PostgreSQL query inconsistency

Hi again, I am trying to execute this SQL command: SELECT page.page_namespace, pagelinks.pl_namespace, COUNT(*) FROM page, pagelinks WHERE (page.page_namespace <=3 OR page.page_namespace = 12 OR page.page_namespace = 13 ) AND (pagelinks.pl_namespace <=3 OR pagelinks.pl_namespace ...

summation of second table grouped by results of first table

Using MySQL syntax, how would I write a query to return the following (I am including the two table descriptions and the relationship between them): TABLE_A (ID, DATE, TABLE_C_ID) TABLE_B (ID, AMOUNT, TABLE_A_ID) TABLE_C (ID) I want to return the following, with the specified limitations: SELECT TABLE_A.ID, TABLE_A.DATE ...

SQL Delete (Suspended in activity monitor)

I have a table containing hundreds of entries and I am trying to delete a small range. It is taking a long time, in fact it is not being executed. I monitored the query from the activity monitor and its status is "Suspended" Is there anyone knows what may cause this problem? ...

PosgreSQL Query Optimization and the Postmaster Process'

Hi again, I currently working with a larger wikipedia-dump derived PostgreSQL database; it contains about 40 GB of data. The database is running on an HP Proliant ML370 G5 server with Suse Linux Enterprise Server 10; I am querying it from my laptop over a private network managed by a simple D-Link router. I assigned static DHCP (private...

How to limit SQL queries CPU utilization?

After a large SQL Query is run that is built through my ASPX Pages I see the following two items listed in sql profiler. Event Class TextData ApplicationName CPU Reads Writes SQL:BatchCompleted Select N'Testing Connection...' SQLAgent - Alert En...

SQL Server - Using a column alias in a subquery

I have the following query which works fine with MySQL but refuses to work with SQL server: SELECT table1.someField AS theField, COUNT(table2.someField) / (SELECT COUNT(someField) FROM table1 WHERE someField = theField), FROM table1 LEFT JOIN table2 ON table1.someField = table2.someField SQL Server doesn't seem to like the ali...

What is the restful approach to compose a group by query

consider the following http request: GET /defects?group-by=priority I would like the returned collection(feed) of defects to be grouped by their priority. i.e. the returned feed consists of defects(resources) and group infromation. I thought about something that will return the groups' titles and count before returning the collection...

PostgreSQL - Correlated Sub-Query Fail?

I have a query like this: SELECT t1.id, (SELECT COUNT(t2.id) FROM t2 WHERE t2.id = t1.id ) as num_things FROM t1 WHERE num_things = 5; The goal is to get the id of all the elements that appear 5 times in the other table. However, I get this error: ERROR: column "num_things" does not exist SQL state: 42703 I'...

Data structure or algorithm for second degree lookups in sub-linear time?

Is there any way to select a subset from a large set based on a property or predicate in less than O(n) time? For a simple example, say I have a large set of authors. Each author has a one-to-many relationship with a set of books, and a one-to-one relationship with a city of birth. Is there a way to efficiently do a query like "get all...

Use Single Row Query with MySQL and PHP

Hey there say I have this $result = mysql_query('SELECT views FROM post ORDER BY views ASC'); and I want to use the value at index 30 I assumed I would use mysql_data_seek($result, 30); $useableResult = mysql_fetch_row($result); echo $useableResult . '<br/>'; But that is returning my whole table What have I got wrong? Edit: Woo...

Best approach to SQL Server query using distinct

Hi Folks, I've two tables: TableA and TableB, joined by TableA.TableA_Id->1..n<-TableB.TableA_Id. A simple PK-FK. I need to extract distinct TableA records given a certain condition on TableB. Here's my 1st approach: SELECT * FROM TableA A INNER JOIN TableB B ON A.idA = B.IdA AND B.Date = '2009-01-10' ORDER BY A.Id; This is nice, bu...

Query to replace a comma in SQL?

Hi, I have a table with the columns employee, address, city, state and zipcode. I have merged address, city, state, zipcode to a single column 'address' separating each field by comma. My issue is, if one of the fields is null, an extra comma will be inserted. For example if city is null the resulting value will be like address,,state...

How can I avoid runtime error 3075 when running this Access VBA query?

Can someone tell what is wrong with this query? sqltext = "SELECT utyp, count(*) AS anzahl INTO UTYP_Anzahl FROM 01_umwelt WHERE [01_umwelt].status = Me.Controls(""STATUS"").Value GROUP BY utyp;" I am getting run time error 3075. ...

group by query challenge

Hi, I have these tables: customer -------- customer_id int name varchar(255) order ----- order_id int customer_id int discount boolean I can get the number of orders made by each customer with a query like: select c.id, count(o.order_id) from customer c left join order as o using c.customer_id = o.customer_id group by...