Query Help

M

mahmad

Hi,

I am hoping someone can help me. What i am trying to do overall is to get
data out of my sql db. Build a quiery within Access and output the data as a
ms datasheet with a chart. Sorry for the long question. I am not great with
sql and access.

So within my sql db i have 4 groups.
Red, Blue,Green, Yellow

When a sale is taken it is given to a group as above.

What i want to do is to pull up the data for each group sum the total sale
and display both the group, the total sale and the date onto a data access
sheet and on a chart.

I have setup a view within my sql server, which gives me the data i need. I
need to put all data into one quiery in ms access, how can i do this.

The query below is in my sql db and pull all the data i need for one group.
Is there an easier way to pulling all the data for all groups with this query.

SELECT DISTINCT
salesorders.srep, SUM(salesitems.sprice) AS Expr1,
delv.dtaxd
FROM dbo.salesorders INNER JOIN
dbo.salesitems ON
dbo.salesorders.son = dbo.salesitems.sona INNER JOIN
dbo.delvitems ON
dbo.salesorders.son = dbo.delvitems.dord AND
dbo.salesitems.sonitem = dbo.delvitems.ditem INNER JOIN
dbo.delv ON
dbo.delvitems.delvnoa = dbo.delv.delvno
WHERE (dbo.salesorders.srep = 'blue') AND
(dbo.delv.dedate > CONVERT(DATETIME,
'2008-02-01 00:00:00', 102))
GROUP BY dbo.salesorders.srep, dbo.delv.dtaxd

Thanks for all your help

Mo
 
J

Jerry Whittle

Removing the following from the WHERE clause should do it:

(dbo.salesorders.srep = 'blue') AND

Also you don't need the DISTINCT.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top