Get numberofSales per day when date and number of sales are in the same table!

  • I have two tables ... a table table1 with KampanjID, Number and Date attributes.

    There kampanjID and Date is a composite key.

    Now I want to show TOTAL Number of per day.

    I use this SQL question

    SELECT DISTINCT rKam.Datum, (SELECT SUM (Shipping) FROM rKam)

    FROM rKam

    As shown each date once. BUT in the column where the number of the day, the TOTAL number of ALL days.

    Do I use this code instead:

    SELECT DISTINCT rKam.Datum, Delivery

    FROM rKam;

    As shown dates as many times as there are entries for that date. (There may be various campaigns on the same date).

    I can really bet on this ...

    Anyone have advice how to solve so that the dates shown only once and in the second column so Plussa all the numbers together for that day REGARDLESS what the campaign.

    Or, you can not with the premise that I have a composite key in this table?

    grateful for the quick reply 🙂

    / Niklas

    EDIT: Clarification ... what I want to do is turn up all the dates are the same ... Then add up all the numbers on THESE lines and present this in the date's number ...

    O then so on the next date.

  • look up "GROUP BY"

    this should help

    EDIT:....just seen that this is Access

    in query design use the "Totals" option...this will utilize "Group By"

    ________________________________________________________________
    you can lead a user to data....but you cannot make them think
    and remember....every day is a school day

  • Hi!

    Thanks for the reply

    I tried

    SELECT Date, NumberofSales

    FROM rKam //(the valid table)

    GROUP BY Date

    That gives me an error message: "You tried to execute a query that does not include the specified expression "NumberofSales" as part of an aggregate function"

    Any tips?:-)

  • Never mind, i figured it out! millions of thank you´s!!!!!!!

    You´re a lifesaver!

  • you are very welcome...pleased to hear you have got this sorted.

    thanks for the feedback.

    ________________________________________________________________
    you can lead a user to data....but you cannot make them think
    and remember....every day is a school day

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply