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.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 Can anyone help me with this Sql syntax plss..

Author  Topic 

yasinirshad
Starting Member

18 Posts

Posted - 2007-08-30 : 08:40:48
Hi.. I want to join this query
[CODE]select Count(*) from iCalls_Events where Call_ID = " & Session("Call_ID") & "select Count(*) from iCalls_Events where Call_ID = "& Session("Call_ID") & " and Events_Flag <> 0[/CODE]
in this query
[CODE]select iCalls_Calls.Call_ID,iCalls_Calls.Requestor,Type,Scope,iCalls_Calls.Status_ID,iCalls_Status.Status_ID,iCalls_Status.Status_Label from ((iCalls_Calls inner join iCalls_Status on iCalls_Calls.Status_ID=iCalls_Status.Status_ID ) inner join iCalls_Users on iCalls_Calls.Requestor=iCalls_Users.User_ID) left outer join iCalls_Messages on iCalls_Calls.Call_ID=iCalls_Messages.Call_ID where Requestor='" & Session("User_ID") & "' AND iCalls_Calls.Status_ID <> 6 order by iCalls_Calls.Call_ID[/CODE]
The Place where i need to Join is after
[CODE]iCalls_Status.Status_ID,iCalls_Status.Status_Label [/CODE]
and before
[CODE]((iCalls_Calls inner join iCalls_Status on iCalls_Calls.Status_ID=iCalls_Status.Status_ID )[/CODE]
I want to add ( / ) in between these 2 queries. The reason is for example first query will return '5' and second '10' , so the output i need is 5 / 10. And i need to put this query in a variable (Countrec) (as i need to bind Countrec to a repeater list ) like
[CODE]select Count(*) from iCalls_Events where Call_ID = " & Session("Call_ID") & " ( / )select Count(*) from iCalls_Events where Call_ID = "& Session("Call_ID") & " and Events_Flag <> 0 as Countrec[/CODE] . I HAVE TO BIND THIS "Countrec" in the repeater list.The Final Query would be something like this
[CODE]select iCalls_Calls.Call_ID,iCalls_Calls.Requestor,Type,Scope,iCalls_Calls.Status_ID,iCalls_Status.Status_ID,iCalls_Status.Status_Label, select Count(*) from iCalls_Events where Call_ID = " & Session("Call_ID") & " ( / )select Count(*) from iCalls_Events where Call_ID = "& Session("Call_ID") & " and Events_Flag <> 0 as Countrec from ((iCalls_Calls inner join iCalls_Status on iCalls_Calls.Status_ID=iCalls_Status.Status_ID ) inner join iCalls_Users on iCalls_Calls.Requestor=iCalls_Users.User_ID) left outer join iCalls_Messages on iCalls_Calls.Call_ID=iCalls_Messages.Call_ID where Requestor='" & Session("User_ID") & "' AND iCalls_Calls.Status_ID <> 6 order by iCalls_Calls.Call_ID[/CODE]
but this syntax is not correct..Please can U get me the Correct Syntax.

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-08-30 : 08:53:23
Where is the query?


E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page
   

- Advertisement -