Quantcast
Channel: Transact-SQL forum
Viewing all articles
Browse latest Browse all 23857

Select Statement 3 tables, and Sum of one column

$
0
0

First let me say I have never taken any classes on sql.  We just started supporting a new POS and it uses a access database, I am just learning this as I go.  This is the statement I currently have.

select C.FNAME, C.LNAME, C.BNAME, C.AC1, C.PHONE1, C.EMAIL, H.RO_NO, T.TECH_NAME, H.RODATE, H.TOTAL
from (CUSTOMER AS C
inner join HRO AS H
on C.CUST_NO=H.CUST_NO)
inner join Tech AS T
on H.WRITER=T.TECH
where H.RODATE between #1/01/2012# and #4/25/2012# and H.TOTAL>1000 order by H.TOTAL DESC

This pulls up the correct info, but it will pull duplicates if the customer has come in multiple times in the date selected.  I want to know if there is a select statement where it will look for duplicate names, add the total column up and only print out one instance of that customer with the sum of the total column.

it currently pulls like this

FNAMELNAMEBNAMEAC1PHONE1RO_NOTECH_NAMERODATETOTAL
RICHARDBB, RICHARD555555-55550091495TED4/6/20122466.53000
RICHARDBB, RICHARD555555-55550091212TED3/20/20121234.77000

I want it to pull like this

RICHARDBB, RICHARD555555-55550091495TED*******

3701.3000

I don't care about the date column, it's just there for reference right now.

Any input on this will be greatly appreciated.

Thank,

           Jeff


Viewing all articles
Browse latest Browse all 23857

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>