Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


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


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

Author
Message
nigge_e
nigge_e
Forum Newbie
Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: General Forum Members
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.
J Livingston SQL
J Livingston SQL
Hall of Fame
Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)

Group: General Forum Members
Points: 3456 Visits: 33045
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

nigge_e
nigge_e
Forum Newbie
Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: General Forum Members
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?:-)
nigge_e
nigge_e
Forum Newbie
Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: General Forum Members
Points: 3 Visits: 1
Never mind, i figured it out! millions of thank you´s!!!!!!!
You´re a lifesaver!
J Livingston SQL
J Livingston SQL
Hall of Fame
Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)Hall of Fame (3.5K reputation)

Group: General Forum Members
Points: 3456 Visits: 33045
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

Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search