Results 1 to 3 of 3
  1. #1
    Join Date
    Jun 2005

    Unanswered: Urgent Help in Sql Statment

    HI all
    i wrote this code in vb 6

    i wrote this code to get all the qty in Different Year
    fd1 =1/1/2004

    Dim i As Integer
    Dim k As Integer
    k = List2.ListCount
    For i = 0 To k
    rs.Open "Select " & Y1 & ", Sum(Qty) As Qty From CarSales WHERE
    " & M0 & "= '" & List2.List(i) & "' And CDate Between #" & fd1 & "# and #" & td1 & "# Group By CarSales." & Y1 & ""

    Next i
    Set DataGrid1.DataSource = rs

    i didnt get all the quantity i just Get The First Record In the data and it give this
    2004 9
    2005 21

    and when i test the code it goes over all the list2 items
    and it just give the first record Between the 1/1/2004 and 31/12/2006

    i really need ur help as soon as possible

    Sami Al Damiri ...

  2. #2
    Join Date
    Jun 2004
    Arizona, USA
    You've written an aggregate query - it is summing up the QTY field, as grouped by year.

    It says that in 2004, your SUM of all the qty fields was 9, and in 2005, the sum of all the qty fields was 21.
    "Lisa, in this house, we obey the laws of thermodynamics!" - Homer Simpson
    "I have my standards. They may be low, but I have them!" - Bette Middler
    "It's a book about a Spanish guy named Manual. You should read it." - Dilbert

  3. #3
    Join Date
    Jun 2005
    I know That
    But The Table Contains 15 Car Model
    I wanted Aggregate the model i choose then appear like this
    Sales Year Qty
    2004 16 this Qty for Toyota,Nissan, Opel, Audi
    2005 50 this Qty for Toyota,Nissan, Opel, Audi
    2006 200 this Qty for Toyota,Nissan, Opel, Audi

    i hope u get what i need to help

    For That I make For LOOP
    To get all the Model i need then it aggregate it

    please all i need Help
    Sami Al Damiri ...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts