Something wrong with my query, what am I doing wrong?

Posted on 2011-10-31
Medium Priority
Last Modified: 2012-05-12
There is something wrong with my query, what am I doing wrong?
select	mmatter, mdesc1, 
		tklast + ', ' + tkfirst + ' (' + tkinit + ')' as WA,
		sum(hwacur) as MTD_Billable_hours,
		sum(hwaytd) as YTD_Billable_hours
from df_dwtkmat , df_dwcontrol, matter, timekeep
where matter in (select	distinct  mmatter from timecard
					where ttk='02500'
					and tworkdt between getdate()-30 and getdate())
and rectype=4020
and defvalue=pe
and matter=mmatter
and watty=tkinit
group by mmatter, mdesc1, 
		tklast + ', ' + tkfirst + ' (' + tkinit + ')'
having sum(hwacur) <> 0 or
		sum(hwaytd)<> 0
order by 		mmatter, mdesc1, 
		tklast + ', ' + tkfirst + ' (' + tkinit + ')'

Open in new window

Question by:VBBRett
LVL 29

Expert Comment

ID: 37059346
Well, to be honest with you, we don't know unless you tell us.
LVL 15

Expert Comment

ID: 37059354
What is the error message you're getting?
LVL 70

Accepted Solution

Scott Pletcher earned 2000 total points
ID: 37059811
It's literally impossible for us to tell which column comes from which table.

You need to specify an alias for every table in the query and prefix every column with a table alias.

Then we'd have a chance of determining what might be wrong / missing.

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

INTRODUCTION: While tying your database objects into builds and your enterprise source control system takes a third-party product (like Visual Studio Database Edition or Red-Gate's SQL Source Control), you can achieve some protection using a sing…
Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question