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 |
|
imranabdulaziz
Yak Posting Veteran
83 Posts |
Posted - 2008-04-03 : 00:16:36
|
Hi all, i am using sql server 2005.let me explain the scenario.i am writing a function that return no of call a sales execituve done.an executive can present n no of product to one customer but that call will be only onemy table record look like empid custid product date and other fieldem111 iimran aaaa 01-04-2008 ........em111 iimran bbbb 01-04-2008 ........em111 iimran cccc 01-04-2008 ........em111 xxxxxx aaaa 01-04-2008 ........em111 xxxxxx 2222 01-04-2008 ........em111 iimran aaaa 02-04-2008 ........em111 iimran bbbb 02-04-2008 ........em111 iimran cccc 02-04-2008 ........em111 xxxxxx aaaa 02-04-2008 ........em111 xxxxxx 2222 02-04-2008 ........Now if i select total no of call it should give me four callalso i am getting this through this queryselect dcr_date , cust_id from vwdcrdtl where emp_id = @empcode and dcr_date between @stdate and @enddate group by dcr_date , dcr_cust_id this query correctly return 4 rowcount(which i am gerring though @@rowcount) but i want this rowcount to return from functioni assinged this to rowcount to int veriable but this giving me error .i would like to know how can i get count of these recordsPlease Help |
|
|
LoztInSpace
Aged Yak Warrior
940 Posts |
Posted - 2008-04-03 : 01:49:11
|
| select count(*) from(select dcr_date , cust_id from vwdcrdtl where emp_id = @empcode and dcr_date between @stdate and @enddate group by dcr_date , dcr_cust_id)xor select count(distinct cast(dcr_date as varchar) + cast(cust_id as varchar)) from vwdcrdtl where emp_id = @empcode and dcr_date between @stdate and @enddate (I think) |
 |
|
|
|
|
|