SQL Server - Distinct Qry
Asked By Smith
09-Feb-12 02:28 AM
how to use distinct condition in this qry ?
cmd = new SqlCommand("select sum(credit) AS total from creditadd where cid<=cid and userid='" + TextBox1.Text + "' and username='" + TextBox2.Text + "'", con);
Web Star replied to Smith
Distinct with aggregate function work little bit different as follows
cmd = new SqlCommand("select sum(DISTINCT credit) AS total from creditadd where cid<=cid and userid='" + TextBox1.Text + "' and username='" + TextBox2.Text + "'", con);
Smith replied to Web Star
this distinct qry is not executing correctly dear, still error ?
cmd = new SqlCommand("select sum(DISTINCT credit) AS total from creditadd where cid<=cid and userid='" + TextBox1.Text + "' and username='" + TextBox2.Text + "'", con);
Web Star replied to Smith
What errror you are getting ?
Somesh Yadav replied to Smith
Hi i will give you a sample example of how to use a distinct condition,
here it comes :-
SELECT DISTINCT CategoryName,Sum(ProductSales) AS CategorySales
i hope you understood and procced further.
SQL Server VC++ SQL Server , What's the easiest / quickest way to connect to SQL Server 2005 from VC++ 2005? then I will do some DB query and plug the result set into C++ objects SQL Server Programming Discussions SQL Server 2005 (1) SQL Server (1) ADO.NET (1) SqlCommand (1) SqlClient
VB.NET / SQL Server SQL Server I???m using VB.NET 2008 and SQL Server 2005. I???m using the table ???tblEmployees??? from database ???DBMain???. The table look like the that? . . . Dim oVar as String oVar = SELECT Firstname FROM tblEmployees WHERE ID = ???2??? ??? Tanx; Nicolas SQL Server Programming Discussions SQL Server 2005 (1) SQL Server (1) Console.WriteLine (1) VB.NET (1
space planning for SQL Server SQL Server Hi I am looking for a script that will enumerate all the DBs on a sql server, show me the used MB and the max MB allocated per db. My intent would isn’t returning anything on it. Can someone aim me in the right direction? thanks SQL Server Discussions SQL Server (1) Exec (1) Disk (1) SqlDataAdapter (1) Database (1) AdventureWorks (1) SqlParameter
Why_can’t_recursive_queries_contain. . .? SQL Server hi I hope I didn = 92t put too many questions 1) Why can = 92t recursive queries also be unioned together with UNION operator ( instead they must use UNION ALL )? thanx SQL Server Programming Discussions SQL Server 2008 (1) SQL Server 2005 (1) SQL Server 2000 (1) SQL Server (1) Oracle (1) Ruby (1) MichaelcoAToptonlineDOTnet (1
DBCC Memorystatus Results across a linked server SQL Server declare @lnvc_SQL nvarchar(4000) select @lnvc_SQL = N'select * from openquery([HQAPPSQL04], ''set fmtonly off; ' + ' exec lnvc_SQL Does anyone know why this only returns 1 result and not all of them? SQL Server Programming Discussions Microsoft.SqlServer.Server.SqlProcedure (1) SQL Server 2008 (1) SQL Server 2000 (1) SQL Server (1) Microsoft.SqlServer.Server (1) System.Data