Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
rlull
Starting Member
39 Posts |
Posted - 2005-11-14 : 15:03:18
|
| I am using the following query from an ASP page:select Orders.CustIDinto #TempTablefrom Ordersjoin Customerson Orders.CustID = Customers.CustIDgroup by Orders.CustIDhaving count(Orders.CustID) = 1select count(*) as NewCustomersfrom #TempTable tjoin Orders oon t.CustID = o.CustIDwhere cast(convert(char(10), OrderDateTime, 112) as smalldatetime) = cast(convert(char(10), '11/10/2005', 112) as smalldatetime)drop table #TempTableWhen I run this in Query Analyzer it works fine and returns a column called "New Customers". However, when I run it from the ASP page or even as a stored procedure, the column is not available. Can anyone help me with this? Thanks. |
|
|
X002548
Not Just a Number
15586 Posts |
|
|
rlull
Starting Member
39 Posts |
Posted - 2005-11-14 : 15:11:41
|
| I was unable to get a single query to accomplish this same task. I'm sure there's a better way to simplify it and would appreciate your suggestions on that as well. |
 |
|
|
TG
Master Smack Fu Yak Hacker
6065 Posts |
Posted - 2005-11-14 : 15:52:30
|
I don't know the answer to you asp/temp table issue but will this do it for you?select count(*) as newCustomersfrom orderswhere datediff(day,OrderDateTime,'11/10/2005') = 0and custid in (select custid from orders group by custid having count(*) = 1) Be One with the OptimizerTG |
 |
|
|
rlull
Starting Member
39 Posts |
Posted - 2005-11-14 : 16:06:59
|
| Yes! Thank you very much. Optimizing the query like that allowed me to retrieve the data properly. |
 |
|
|
|
|
|