Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Development (2000)
 some sql programming scenarios -- need help

Author  Topic 

mike14
Starting Member

1 Post

Posted - 2004-01-27 : 16:01:39
I need some analytical sloution any or all of the above if you can. Or suggest me some useful sites where I can find important info about them.


Q1: What is the problem with this statement? How would you fix it?

Select *
From Table_A
Where Field1 = Null
and Field2 <> Null


Q2: You have Table_C with 1,000,000 rows. You are asked to write a statement that is executed periodically (say each hour) from SQL Executive (6.5) or SQL Agent (for 2000). The purpose of this statement is to set all the rows on Table_C to a value 0 on the field "field1". Why is this statement a really bad idea? How would you improve it?

Update Table_C
Set field1 = 0



Q3: Consider this table:

Create table Table_D
(
Id int identity(1,1),
JobId int not null,
ts Timestamp
)

Please write the SQL that returns the entire record (through a SELECT * ) that has the highest timestamp for JobId = 1234?


Q4: Same as above. Please write the SQL that returns the record that has the 2nd highest timestamp (that is, not the highest timestamp, but the one just below it), for JobId = 1234


Q5: Which indexes would you recommend so that the queries above would run fast? You can consider that the table has 100,000 rows, and each JobId usually appears on 1,000 records.




Thanks,
Mike.

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2004-01-27 : 16:03:16
Are these homework/test questions? We don't answer school questions here.

Tara
Go to Top of Page

MichaelP
Jedi Yak

2489 Posts

Posted - 2004-01-27 : 17:58:03
Yes, this smells of homework.

Michael

<Yoda>Use the Search page you must. Find the answer you will.</Yoda>
Go to Top of Page
   

- Advertisement -