Archive for the 'subquery' Category

Help with SQL query please?

Could i please get some help with another query please.
my tables are
Student ( (pk)student_id, student_name, teacher_id)
Student_Subject ( (pk)student_id, (pk) subject_id, mark)
subject ( (pk)subject_id, subject_name)
Okay I am trying to do a correlative subquery to produce a listing showing the MAXIMUM MARK obtained by each STUDENT (regardless of subject). Output needed, Student_id, student_name, subject_name and maximum mark.
i [...]

I need answers for the fallowing qurries?

1. Which of the following are valid group functions? (choose 3)
a) ROUND
b) COUNT
c) DIFF
d) MAX
e) AVG
2. How do you display the salary amount in column sal of table emp in words?
a) Select sal, (to_char(to_date(sal,’j’), ‘jsp’)) from emp
b) Select sal, (to_char(to_date(sal))) from emp
c) Select sal, (to_char(to_date(sal), ‘jsp’)) from [...]

Indexes in sql server?

When clustered and non-clustered index ( in SQL SERVER ) should be used ?
And what is correlated subquery ? Example please.
Thanks in advance.
As a rule of thumb, every table should have a clustered index. Generally, but not always, the clustered index should be on a column that monotonically increases–such as an identity column, or some [...]

SQL question, can you help please?

how can I use this without having a subquery?
select bright, sum(height) from (
SELECT sum(a.myheight) height, b.bright
FROM table1 a,
Table2 b
where a.id=b.id
group by b.bright
union all
SELECT sum(a.myheight) height, b.bright
FROM table1 a,
[...]

SQL question, can you help please?

how can I use this without having a subquery?
select bright, sum(height) from (
SELECT sum(a.myheight) height, b.bright
FROM table1 a,
Table2 b
where a.id=b.id
group by b.bright
union all
SELECT sum(a.myheight) height, b.bright
FROM table1 a,
[...]

SQL problem in Microsoft Access?

I have a subquery within a query I am writing in MS Access which works perfectly but when I close the query and then reopen it later, bits of it has been automatically reformatted/changed by the program and it stops working.
Access turns the parentheses ( ) around my subquery into square brackets followed by a [...]

how to find nth greatest value using max command in SQL?

can u slove my problem..any SQL user can slove it
hey if i have ten records in my salary coloumn and i want to know the salary of the 5th greatest one.but use the subquery command take lot of time (select from max(sal) from emp where sal<(select from max(sal) from emp) writng this 5 times [...]

Easy question about SQL, 10 Points!?

Write a SQL statement to show the Initials, Name and TotalPay (HoursWorked * Salary/hour) grouped per employee for the first 15 days of May 2006.
Consider that the salary per hour is $12.
-totalpay is a new column that needs to be added with a ‘alter’ statement, possible subquery
Home work?
Here is a guide:
http://www.sql-ex.ru/help/

I am getting following error message while i am executing the query?

This is my query:
select * from tbl_test1 where tbl_test1.name = ( SELECT name from tbl_test4 where tbl_test4.name != ‘Sajeesh’)
( in mysql )
and erro message is :
subquery returns more than one row.
Your subquery is returning more than 1 row of data, i.e. morethan one row with the name you have specified and hence cannot be worked [...]

What’s the difference between and Join and a Subquery (T-SQL)?

Its usually different ways of thinking or solving the same problem.
A join will join two or more tables together by a field related to both tables (ie, relationship of primary and foreign keys). It is typically easy to understand.
A subquery statement involves a SELECT statement that selects particular values from a table. The [...]