|
-
May 4th, 2000, 10:11 PM
#1
Thread Starter
Addicted Member
I got these questions on a recent interview if you want to answer you can, but please give some explanation as to how you got the answer or jot them down and learn them -- just for fun . . . I'll post my answers as well
1. N is an integer and N>1. Write a simple program to solve the following problem. Use any computer language or flow chart. Syntax is not critical.
2. Invoice Header File: invhdr
Invoice Number: inv_no
Date sold: inv_dt
Customer ID: inv_cust
Invoice Detail file: invdtl
Invoice Number: inv_no
Item ID: inv_item
Quantity(integer):inv_qty
Write a SQL statement to provide the following information.
Total quantity sold for item ID 10101 during February, 2000, excluding Customer ID 21225.
3. Assume that the above tables don’t have any indexes. What indexes will you create to improve the performance of that particular statement? Write SQL statements to create indexes.
-
May 5th, 2000, 12:31 AM
#2
I'm afraid that doesn't make a lot of sense!
What are the questions, and which are your answers? Could you write it a bit more clearly?
-
May 5th, 2000, 12:33 AM
#3
Addicted Member
Im glad Im not the only one who didn't understand it =)
Thai
-
May 5th, 2000, 01:04 AM
#4
Thread Starter
Addicted Member
There are no answers so far.
1. is the first question
2. .. is the second question
3.. is the third question.
-
May 5th, 2000, 01:07 AM
#5
Thread Starter
Addicted Member
Here is an answer posted by John Percival, editor of VB World regarding question number 1:
Dim sum As Long, n As Integer
sum = (2 * n + 1) * (n + 1) * n / 6
I had asked this as a separate question all by itself.
Question #1 again was N is an integer, N>1
problem:
1+2+3+...+N=?
Answer from John:
Dim sum As Long, n As Integer
sum = (2 * n + 1) * (n + 1) * n / 6
both questions 2 and 3 are regarding SQL
-
May 5th, 2000, 02:06 AM
#6
Addicted Member
-
May 5th, 2000, 02:19 AM
#7
Thread Starter
Addicted Member
Here's what i got for number 1.
A=0
if N=3
for next loop
A=A+N
-
May 5th, 2000, 02:58 AM
#8
Member
Reply to Q2
select invdtl.inv_qty
from invdtl inner join invhdr on
invdtl.inv_no = invhdr.inv_no
group by invdtl.inv_item, invhdr.inv_dt,
invhdr.inv_cust, invdtl.inv_qty
having (invdtl.inv_item=10101) and
(invhdr.inv_dt between "02/1/2000"
and "02/29/2000") and
(invhdr.inv_cust<>21225)
compute sum(invdtl.inv_qty)
-
May 5th, 2000, 03:59 AM
#9
Addicted Member
Answer to question 2.
Q2.
SELECT Sum(INV_QTY) AS TTL_QTY
FROM Invhdr
INNER JOIN invdtl ON Invhdr.INV_NO = invdtl.INV_NO
WHERE (INV_ITEM=10101)
AND (Month([INV_DATE])=2)
AND (Invhdr.INV_CUST<>21225);
I used Access to knock this up, its a great SQL calculator.
-
May 5th, 2000, 04:25 AM
#10
Thread Starter
Addicted Member
How did you do that did you created different tables or data? could you please explain your answer. Sheesh I sound like a school teacher
-
May 6th, 2000, 05:22 AM
#11
Addicted Member
Yes, I just set up some tables, joined the common fields and set the criteria. I also used relevant data that would filter through the criteria and give me a result.
Although I know SQL and could have written this it was much easier to set this up in Access. Once I had my result I just went view SQL. Access was my SQL teacher, it is so easy to learn SQL by first setting up the objects in a GUI and after you have the result just view SQL and voila!
There are various ways you could have written this SQL and obviously it depends on the tool/language extensions. I am not sure if I strictly stuck to ANSI standard here.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|