Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Get numberofSales per day when date and number of sales are in the same table! Expand / Collapse
Author
Message
Posted Friday, February 17, 2012 8:52 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, February 17, 2012 9:10 AM
Points: 3, Visits: 1
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.
Post #1253954
Posted Friday, February 17, 2012 8:57 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Today @ 8:40 AM
Points: 1,943, Visits: 20,149
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
Post #1253959
Posted Friday, February 17, 2012 9:10 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, February 17, 2012 9:10 AM
Points: 3, Visits: 1
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?
Post #1253970
Posted Friday, February 17, 2012 9:16 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, February 17, 2012 9:10 AM
Points: 3, Visits: 1
Never mind, i figured it out! millions of thank you´s!!!!!!!
You´re a lifesaver!
Post #1253975
Posted Friday, February 17, 2012 9:56 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Today @ 8:40 AM
Points: 1,943, Visits: 20,149
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
Post #1254011
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse