Archive for the 'subquery' Category

How to calculate the difference of the same field in two rows in Microsoft Access?

I have a table that has clock in time in one row and clock out time in another row. I need to be able to sum the hours worked in a day.
TIMESTAMP ETEMP# ETIORO PMNAME
1/2/09 8:56 AM 213 I John Deere
1/2/09 1:15 PM 213 O John Deere
1/2/09 1:43 PM 213 I John Deere
1/2/09 6:03 PM [...]

how do you create a subquery in access?

what would you do/type?
select
from employees;
the easy way to get into that is to build 2 queries and use the query designer instead of trying to write sql code first.
so, let’s say you have an ‘employees’ table and a table that tracks absences and they’re keyed on an employee id field
in you primary query from the [...]

Hi, does any1 have Oracle answers to these q’s? Thanks!?

12.Using a WITH clause write a SELECT statement to list the job_title of those jobs whose maximum salary is more than half the maximum salary of the entire company. Name your subquery MAX_CALC_SAL. Name the columns in the result JOB_TITLE and JOB_TOTAL, and sort the result on JOB_TOTAL in descending order. Hint: Examine the jobs [...]

MS Access Help?

I have a form that includes numerous Bonus codes. I labelled the fields as BC1, BC2, BC3……BC12. ( in the table)
The bonus code is a number and it varies from 100 to 114. After having numerous records, I now want to do a query that will give me all my bonus code entries ( [...]

Database / SQL question – this is hard?

I have two tables that use either three or four logical keys to determine duplication. I need to populate the 3-key table with the 4-key’s unique field. The keys map like this
3-Key
ABC
4-Key
ABCD
I need to get D, put it into 3-key, when there’s a match based on ABC. Here’s the catch. ABC [...]

SQL: Cant link sub-queries?

Im supposed to list the names of actors who have stared in more than 3 films
This is wrong but its all i can think of and everything needed should be there.
SELECT fname, surname
FROM actor
WHERE a_id=(SELECT actor_id FROM acts WHERE movie_id=(SELECT Count(*) FROM acts GROUP BY actor_id HAVING (COUNT(*)>3)));
Its wrong in the first subquery but i [...]

I need some help writing a sql query?

I am wanting to figure out how to write a query that will select specific rows from different tables, which shouldnt be a problem, i will just use the related keys to relate the tables. there is one table that I need to do something different with. In this table, the key will relate to [...]

How do I insert multiple rows in MySQL using nested select statements?

e.g. insert into lmms.household (id,family_name,location_id,last_update_time,last_update_user_id,creation_time,creation_user_id) values
((select households_id from world.households),(select family_name from world.households),"93469603",(select last_updated from world.households),"1",(select created_date from world.households),"1");
returns an error- "subquery returns more than one row"?
How can this statement be re-written?
select households_id from world.households
select family_name from world.households
select last_updated from world.households
those statements need to be 1 row.
just put a conditional like where whatever = whatever

How to display counted value of database column using count function in php?

I have two tables (newassignment,bugstatus) I have made one query i.e
$query = "select assign_name,credit,(select count(bug_id) from bugstatus where client_userid=2 and assign_id=2 group by bug_status having bug_status=’Approved’),(select count(bug_status) from bugstatus where client_userid=2 and assign_id=2 group by bug_status having bug_status=’Pending’) from newassignment where client_userid=2";
this query is executed in mysql but I don’t understand how to display this [...]

Subqueries in MySQL 4.1?

If I do a query for:
select id from table1 where user="me"
I get a list of 5 items.
Now I want to exclude those 5 ids from another query, with something like this:
select content from sentences where id NOT IN ( (select id from table1 where user="me") )
But that gives me an error of "Subquery returns more [...]