Results 1 to 11 of 11

Thread: Can you get this VB job?

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Mar 2000
    Location
    bebenia, PA, USA
    Posts
    241
    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.






  2. #2
    Guest

    Smile 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?

  3. #3
    Addicted Member
    Join Date
    Mar 2000
    Posts
    168
    Im glad Im not the only one who didn't understand it =)

    Thai

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    Mar 2000
    Location
    bebenia, PA, USA
    Posts
    241
    There are no answers so far.

    1. is the first question

    2. .. is the second question

    3.. is the third question.


  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Mar 2000
    Location
    bebenia, PA, USA
    Posts
    241
    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



  6. #6
    Addicted Member
    Join Date
    Mar 2000
    Location
    Gainesville, FL
    Posts
    131
    fools!

  7. #7

    Thread Starter
    Addicted Member
    Join Date
    Mar 2000
    Location
    bebenia, PA, USA
    Posts
    241
    Here's what i got for number 1.

    A=0
    if N=3
    for next loop
    A=A+N


  8. #8
    Member
    Join Date
    Jan 2000
    Location
    Southbridge, MA, USA
    Posts
    40

    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)

  9. #9
    Addicted Member
    Join Date
    May 2000
    Location
    London Occupation: Desktop Developer
    Posts
    141

    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.

  10. #10

    Thread Starter
    Addicted Member
    Join Date
    Mar 2000
    Location
    bebenia, PA, USA
    Posts
    241
    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

  11. #11
    Addicted Member
    Join Date
    May 2000
    Location
    London Occupation: Desktop Developer
    Posts
    141
    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
  •  



Click Here to Expand Forum to Full Width