query help urgent needed

  • Thread starter Thread starter subs
  • Start date Start date
S

subs

ocity dcity client paiddate mode wgt cost
A B gpi 1/2/08 L 10 20000
C D ppg 2/2/08 T 27 18999
E F sunc 1/4/08 C 78 1111
A B gpi 3/1/08 E 86 456
O G gpi 3/5/08 T 60 245
C D ppg 5/1/08 O 78 444

i have hundreds of records like above. i want a query where it
should ask the user to enter ocity , dcity and client and then based
on this input, the query should give the follwoing output. Also user
wants to query this based on particular paid date

ocity dcity sumofwgt sumofcost
A B 96 20456
E F 78 1111
and so on

what is the easist way to do this? is there a cross tab query or a
parameter query using the grid. If so how to do that. Pls help
 
SELECT ocity, dcity, SUM(wgt), SUM(cost)
FROM tableNameHere
WHERE client = "gpi"
GROUP BY ocity, dcity





You can change the constant "gpi" to a parameter.

Note: the WHERE clause is applied before making the groups and performing
the aggregations (SUMs, here) while HAVING clause, if present, is applied
after.

You could have add:


HAVING SUM(wgt) > 100


as example, but could NOT use

WHERE SUM(wgt) > 100


since where is to be applied before the sum is made.




Hoping it may help,
Vanderghast, Access MVP
 
Back
Top