sql

Add a summary row to MS Access query

I have a query stored in MS Access which is doing a standard select from an Access table. I would like to add a summary row at the end showing sums for some of the data above. I have looked at DSum() but it isn't suitable as I would have to include the running total on each row as opposed to just the end. Also, note that I don't want ...

how to convert result of an select sql query into a new table in ms access

how to convert result of an select sql query into a new table in msaccess ? ...

Set value if it is NULL in sql - Access 2007.

Is it possible to set a value to values who is NULL? The sql I use now is this: SELECT date FROM Activity WHERE date BETWEEN [Forms]![Search]![fromDate] AND [Forms]![Search]![toDate] But the problem is when there is no value for fromDate or toDate the result is zero rows. So what I want to do is when fromDate is NULL, change the from...

Should I use an index column in a many to many "link" table?

I have two tables, products and categories which have a many to many relationship, so I'm adding a products_categories table which will contain category_id and product_id. Should I add another (autoincrementing) index column or use the two existing ones as primary key? ...

SQL - Output a substring based on a search pattern ensuring first/last strings are full words

I have the following query in which I am searching within the XMLData type column. I want to return a substring of a node that either starts with the search criteria and X number of characters afterward ending on a full word or a substring which places the search criteria in the middle of the result with X number of characters before an...

If false, search both true and false in Access sql.

SELECT id FROM Activity WHERE important = see below IF [Forms]![Search]![important] = false, search for both true and false IF [Forms]![Search]![important] = true, search for only true I hope you understand what I want to do. Is this possible? ...

how to combine different objects in ms-access each containing different queries into one object

i have created multiple sequential sql query objects for an ms access database. e.g objectA is named sqlqueryA and contains the sql code Select a, b, ........From TableA objectB is named sqlqueryB and contains the sql code Select a, m, n...... From sqlqueryA objectC is named sqlqueryC and contains the sql code Select x, y...

What's wrong with this simple query using NOT IN?

Schema: radio_bin.id radio.id radio.radio_bin -> radio_bin.id Queries: select * from radio_bin 72 rows. select * from radio_bin where id in (select radio_bin from radio) 50 rows. (And FWIW:) select distinct radio_bin from radio 51 rows, including a null. That's all good. Now: select * from radio_bin ...

Postgresql 8.3, simple query not using index

Hi! I have two tables: table1 (about 200000 records) number varchar(8) table2 (about 2000000 records) number varchar(8) Fields 'number' in both tables have standard indexes. For each record in table1 there is about 10 records in table2 assigned. I execute query: explain select table1.number from table1, table2 where table1.num...

c# Optimized Select string creation loop

I'm looking to optimized this piece of code. It will process 15000 - 20000 lines. For now I have 9000 lines and it take 30 sec approx. I know string concatenation is slow but I don't know how to do it another way. // // Check if composite primary keys existe in database // ...

Is sqlconnection object closed and/or disposed on timeout?

If an sqlcommand is executed and times-out, is the respective sqlconnection closed and/or disposed? Thanks in advance! ...

SQL - Get sales figure in 2 period

I have two tables: one contains employees information and another is transactions (sales) information including sales man (employeee ID) Table 1: employees,code name ... Table 2: sales, employee_code, product, Date, Price, Amount I would like to calculate how much each employees can generate revenue (total amount) for each of 2 period...

Convert SQL query into CakePHP pagination query

How can I use the following query: SELECT * FROM `laps` WHERE `id` = ( SELECT `id` FROM `laps` AS `alt` WHERE `alt`.`user_id` = `laps`.`user_id` ORDER BY `lap_time` ASC LIMIT 1 ) ORDER BY `lap_time` ASC in my CakePHP app and paginate the results? ...

Does deleting row from view delete row from base table - MYsql?

I am trying to decide if I need to use a view for a particular set of tables. I was wondering if when deleting a row from a view, will it delete the appropriate rows from the base tables that the view was created upon? I am using mysql. ...

Order of index on multiple columns

Just a simple question, but does the order of your index matter when it spans over multiple columns? For example, taking the query: SELECT * FROM my_table WHERE (column_1 = 1 AND column_2 = 2) If I want to add an index for a query like this, does it matter if my index is created like this: CREATE INDEX my_index ON my_table (column...

Using outer joins in HQL queries

I'm trying to build a query using HQL and OUTER JOINs and just can't get it work. Consider the following mapping <class name="Parent"> <id name="id" type="integer"> <generator class="native" /> </id> </class> <class name="Child"> <id name="id" type="integer"> <generator class="native" /> </id> <many-to...

VBA string length problem

Hi, I have an Access application where everytime a user enters the application, it makes a temp table for that user called 'their windows login name'_Temp. In one of my reports I need to query using that table, and I can't just make a query and set it as the recourdsource of the report, since the name of the table is always different. ...

Can someone copyright an SQL query?

I work for a school district. Every year we have to export a list of students from our student management system and send it to a company that handles our online exams. So to do this export, we had to hire someone who knew the inner workings of our student management system. He wrote an sql (Adaptive Sybase SQL Anywhere) query to export...

Decent Visual SQL query Builder

I am a code developer, not a DBA, and I tend to get lost with loooong SQL queries, when I use many joins (10 joins is pretty common for me). I would like to find a Visual SQL Query Builder (free if possible) that could connect to Oracle and see all the tables there, so I would only select visually my keys that link the Joins, and selec...

How to compare groups of tuples in sql

How to compare groups of tuples in sql: consider the following example: TABLE T1 -------- GROUP VALUE ----- ----- A FOO A BAR X HHH X ZOO TABLE T2 -------- GROUP VALUE ----- ----- B ZOO C FOO C BAR I want to write an sql query which compares the groups of values...