josereyes
asked on
Filtering on a date range without selecting the date itself
We have a table of products, quantities, retail values
and sales dates . We want to select only the branches,
sum the quantities and sum the retail values by grouping them into a set of weekly date ranges to show sales in a
set of week columns
Problem is SQL asks for sale date to be in an aggregate
function or group by clause even though we don't select it
and sale dates vary so much we are getting duplicate entries on branches where we don't want them.
Any one done this ?
Tried to use an aggregate function on date but SQL still
says its not included etc ...
Our SQL expert is stuck on this too.
and sales dates . We want to select only the branches,
sum the quantities and sum the retail values by grouping them into a set of weekly date ranges to show sales in a
set of week columns
Problem is SQL asks for sale date to be in an aggregate
function or group by clause even though we don't select it
and sale dates vary so much we are getting duplicate entries on branches where we don't want them.
Any one done this ?
Tried to use an aggregate function on date but SQL still
says its not included etc ...
Our SQL expert is stuck on this too.
ASKER
I think my description is adequate enough for experienced
T-SQL writers who have done any date grouping stuff.
ORDER BY has little to do with it. Sorry.
T-SQL writers who have done any date grouping stuff.
ORDER BY has little to do with it. Sorry.
wow! you are telling the #1 of MSSQL and Database topic area he isn't experienced!!?? (just kidding)
Seriously, i have seen this error, but i can't reproduce it right now. I am quite sure that seing your SQL i can see what you have done wrong, or where the problem arises.
CHeers
Seriously, i have seen this error, but i can't reproduce it right now. I am quite sure that seing your SQL i can see what you have done wrong, or where the problem arises.
CHeers
Try selecting the top 100 percent:
select top 100 percent ...
select top 100 percent ...
ASKER
Sorry, our local SQL guru just cracked it using nested SELECT statements. I'm off on vacation for two weeks.
Thanks to all who responded
.........
Jose
Thanks to all who responded
.........
Jose
josereyes,
These questions are still open and our records show you logged in recently. Please resolve them appropriately as soon as possible. Continued disregard of your open questions will result in the force/acceptance of a comment as an answer; other actions affecting your account may also be taken. I will revisit these questions in approximately seven (7) days.
https://www.experts-exchange.com/jsp/qShow.jsp?qid=11324697
https://www.experts-exchange.com/jsp/qShow.jsp?qid=11723798
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20164448
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20165555
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20173349
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20187667
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20193216
EXPERTS: Please leave your thoughts on this question here.
Thanks,
Netminder
Community Support Moderator
Experts Exchange
These questions are still open and our records show you logged in recently. Please resolve them appropriately as soon as possible. Continued disregard of your open questions will result in the force/acceptance of a comment as an answer; other actions affecting your account may also be taken. I will revisit these questions in approximately seven (7) days.
https://www.experts-exchange.com/jsp/qShow.jsp?qid=11324697
https://www.experts-exchange.com/jsp/qShow.jsp?qid=11723798
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20164448
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20165555
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20173349
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20187667
https://www.experts-exchange.com/jsp/qShow.jsp?qid=20193216
EXPERTS: Please leave your thoughts on this question here.
Thanks,
Netminder
Community Support Moderator
Experts Exchange
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
i guess you use it in the ORDER BY...