GridView_1 Category Name SubCategory Name Amount Construction Construction 2,877.00 Design Design 0.00 Soft Cost Inspection 0.00
GridView_2 Category Name SubCategory Name Amount Construction Construction 2,800.00 Construction Contingency 300.00 Design Design 500.00 Soft Cost Inspection 980.00 Soft Cost Survey 145.00 Soft Cost Testing 720.00 Soft Cost Management 1000.00 Soft Cost Other Costs 10,000.00
QUESTION: How could I UNION the two result sets together and where the Category Name and SubCategory Name are equal for GridView1 and GridView2, show the difference in the Amount column.
This is the result I am looking for.
Category Name SubCategory Name DIFFERANCE Construction Construction 77.00 = (GridView1 - GridView2) Construction Contingency 300.00 Design Design 500.00 Soft Cost Inspection 980.00 Soft Cost Survey 145.00 Soft Cost Testing 720.00 Soft Cost Management 1000.00 Soft Cost Other Costs 10,000.00
I am trying to do it on the back end. Though, if you have a clever way to produce a resulting gridview in C# with the results I need, I am all game! This is what I have so far: (TSQL code)
I am trying to pull the number preceeding the decimal, but I want my output in a fixed lengh. Here is what I tried thinking it might work, however it did not.
sf_retail = right('000' + floor(cast(labsf.last_retail_price as varchar)),3),
the number I am running this against is '0000001.45' I would like my output to read '001'......I am getting only '1'
I have a query where I have to use the convert function to return the unitprice as a decimal with 2 digits to the right of the decimal and a $ to the left of the number like 10 should be $10.0o. How do i insert the $. this is my code so far:
SELECT CONVERT(varchar, UnitPrice, 1) AS varchartotal FROM dbo.[Order Details]
I was wondering what is the best way to have a amount paid total from amounts entered to a specific id or column? I am using SQL 2005. I need to be able to tally the total amount paid and put that value in another column called amount paid. Any help would be great. Thanks,
Generally, what would be a good start to model and make predictions based on the following.
Even Dollar Transactions €“ Including transactions that end in $0 or $50 with a Total Transaction Amount between $400 and $5000.
I have a table called Transaction with a BillingAmount column.
I've gone through the SQL Server 2005 Data Mining Tutorial (which uses a discrete prediction BikeBuyer yes or no) and read a lot of Data Mining with SQL Server 2005. Neither of these give good, complete, methodical examples of selecting inputs and targets and making predictions; especially for continuous columns.
I think I'm generally struggling with the concepts of selecting (continuous?) predictable attributes and calculating predictions based on the results. Are there any examples of a scenario similar to the above that I can reference? or just some advise.
How do I count the number of positive dollar values in a query? I have various negative and positive dollar values and want to count how many positive I have then I will know how many are negative. I cannot put >0 or >0.00 in the where because it still returns everything cuz the programmer set the datatype to be money
I have amount field in my table as decimal. I need a query to display the amount with dollar or euro symbol based on country selection. The country also in same table.
For example If country is US then Amount $1200, If country is UK then Amount €1200.
I have a table of orders. I was asked to count the orders that fall into specific dollar buckets. Normally I would use a CASE statement for this, but in this case, there are over 100 different buckets!
For example, I need to count the orders in $5 increments up to $400. The CASE statement would look like this:
Code: CASE WHEN sum(revenue) BETWEEN 0.01 AND 5.00 THEN [0.01 to 5.00] WHEN sum(revenue) BETWEEN 5.01 AND 10.00 THEN [5.01 to 10.00] ... WHEN sum(revenue) BETWEEN 395.01 AND 400.00 THEN [395.01 to 400.00]
Is there an easier way to do this, maybe with a loop?
I am trying to add a field (bank_chk_amt] from a table in to my query to bring in a dollar amount....I originally had this below
SELECT dbo.CBPAYMENT.REFERENCE_NO, 'CCMCCHBREF' AS Literal, RTrim([description]) + ', ' + [bank_chk_amt] + ', ' + convert(char(10),[check_date],101) + ', ' + 'Refund check sent to ' + [payee_name] AS [Free Text] FROM dbo.CBPAYMENT;
but I would get "Error converting data type varchar to numeric".So my co-worker modified it and added (str([bank_chk_amt]) to my query which worked, but I noticed it dropped of the cents. So instead of 80.35 it would show 80 And I noticed it rounded 100.50 to 101...How can I bring in the full dollar amount and without adding?
I need to send the result of a procedure to an update statement.Basically updating the column of one table with the result of aquery in a stored procedure. It only returns one value, if it didnt Icould see why it would not work, but it only returns a count.Lets say I have a sproc like so:create proc sp_countclients@datecreated datetimeasset nocount onselect count(clientid) as countfrom clientstablewhere datecreated > @datecreatedThen, I want to update another table with that value:Declare @dc datetimeset @dc = '2003-09-30'update anothertableset ClientCount = (exec sp_countclients @dc) -- this line errorswhere id_ = @@identityOR, I could try this, but still gives me error:declare @c intset @c = exec sp_countclients @dcWhat should I do?Thanks in advance!Greg
I have an Execute SQL Task that executes "select count(*) as Row_Count from xyztable" from an Oracle Server. I'm trying to assign the result to a variable. However when I try to execute I get an error: [Execute SQL Task] Error: An error occurred while assigning a value to variable "RowCount": "Unsupported data type on result set binding Row_Count.".
Which data type should I use for the variable, RowCount? I've tried Int16, Int32, Int64.
---------------------------------------------------------------------- I executed it in my SQL Server Management Studio Express and I got: Commands completed successfully. I do not know where the result is and how to get the result viewed. Please help and advise.
HI, I ran a select * from customers where state ='va', this is the result...
(29 row(s) affected) The following file has been saved successfully: C:outputcustomers.rpt 10826 bytes
I choose Query select to a file then when I tried to open the customer.rpt from the c drive I got this error message. I am not sure why this happend invalid TLV record
As the topic suggests I need the end results to show a list of shows and their dates ordered by date DESC. Tables I have are structured as follows:
SHOWS showID showTitle
SHOWACCESS showID remoteID
VIDEOS videoDate showID
SQL is as follows:
SELECT shows.showID AS showID, shows.showTitle AS showTitle, (SELECT MAX(videos.videoFilmDate) AS vidDate FROM videos WHERE videos.showID = shows.showID) FROM shows, showAccess WHERE shows.showID = showAccess.showID AND showAccess.remoteID=21 ORDER BY vidDate DESC;
I had it ordering by showTitle and it worked fine, but I need it to order by vidDate. Can anyone shed some light on where I am going wrong?
I am trying to code a WHERE xxxx IN ('aaa','bbb','ccc') requirement but it the return values for the IN keyword changes according to another column, thus the need for a CASE function.
WHERE GROUP.GROUP_ID = 2 AND DEPT.DEPT_ID = 'D' AND WORK_TYPE_ID IN ( CASE DEPT_ID WHEN 'D' THEN 'A','B','C' <---- ERROR WHEN 'F' THEN 'C','D ELSE 'A','B','C','D' END )
I kept on getting errors, like
Msg 156, Level 15, State 1, Line 44Incorrect syntax near the keyword 'WHERE'. which leads me to assume that the CASE ... WHEN ... THEN statement does not allow mutiple values for result expression. Is there a way to get the SQL above to work or code the same logic in a different manner in just one simple SQL, and not a procedure or T-SQL script.
I'm using a subquery to return a delivery charge line as a column in the result set. I want to see this delivery charge only on the first line of the results for each contract. Code and results are below.
declare @start smalldatetime declare @end smalldatetime set @start = '2015-03-22 00:00' -- this should be a Sunday set @end = '2015-03-28 23:59' -- this should be the following Saturday
In this example, I only want to see the delivery charge of 125.00 for the first line of contract HU004377. For simplicity I have only shown the lines for 1 contract here, but there would normally be many different contracts with varying numbers of lines, and I only want to see the delivery charge once for each contract.
Hi All, I need to For Each loop tied back to a SQL result set. This is what I have so far, I know its not much but I'm stuck. Thanks soooo much!TimDim conn As SqlConnectionDim comm As SqlCommandDim reader As SqlDataReaderDim connectionstring As String = ConfigurationManager.ConnectionStrings("Magic").ConnectionStringconn = New SqlConnection(connectionstring)comm = New SqlCommand("Select Distinct([_Group_]) from _Smdba_._Groupdet_ Where [_InActive_:] = 0", conn) Tryconn.Open()reader = comm.ExecuteReader() For Each (FOR EACH SQL RECORD) 'I'm going to put some code in here.... reader.Close()Catch dberrorlabel.Text = "Error Loading Admin Panel"Finally conn.Close()End Try
In 6.5 I ran a SELECT query with a specific WHERE clause. It gave me a result set of 430 rows. But when I use the same conditions in WHERE clause in UPDATE, it updated only 420.
YOU ALL REQUESTED TO HELP ME TO COMEOUT FROM PROBLEM : I HAVE A TABLE NAME PLUCK IN WHICH DATA STORE: MONYEAR EMPCODE PDATE(ddmmyyy) JOBCODE HCD kg 022006 A01608P 01/02/2006 LA N 0 022006 A01608P 02/02/2006 LA N 0 022006 A01608P 03/02/2006 LA N 0 022006 A01608P 04/02/2006 LA N 0 022006 A01608P 05/02/2006 LH N 0 022006 A01693P 01/02/2006 PL N 21 022006 A01693P 02/02/2006 PL N 25 022006 A01693P 03/02/2006 PL N 15 022006 A01693P 04/02/2006 PL N 25 022006 A01693P 05/02/2006 LH N 0
BUT I WANT REPORT LIKE : 022006 A01608P LA N LA N LA N LA N LH N 022006 A01693P 21 N 25 N 15 N 25 N LH N
(IF JOBCODE = PL THAN INSTEAD OF JOBCODE KGPLUCK IS SHOWN..)
Pls guide how to write the SQL to achive the report...
Thanks
ASM
---sample data insert USE NORTHWIND CREATE TABLE PLUCK (MONYEAR CHAR(6), EMPCODE CHAR(7), PDATE SMALLDATETIME,JOBCODE CHAR(2), HCD CHAR(1), KGPLUCK INT)
INSERT INTO PLUCK VALUES('022006', 'A01608P','01/02/2006','LA','N',0); INSERT INTO PLUCK VALUES('022006', 'A01608P','02/02/2006','LA','N',0); INSERT INTO PLUCK VALUES('022006', 'A01608P','03/02/2006','LA','N',0); INSERT INTO PLUCK VALUES('022006', 'A01608P','04/02/2006','LA','N',0); INSERT INTO PLUCK VALUES('022006', 'A01608P','05/02/2006','LH','N',0);
INSERT INTO PLUCK VALUES('022006', 'A01693P','01/02/2006','PL','N',21); INSERT INTO PLUCK VALUES('022006', 'A01693P','02/02/2006','PL','N',25); INSERT INTO PLUCK VALUES('022006', 'A01693P','03/02/2006','PL','N',15); INSERT INTO PLUCK VALUES('022006', 'A01693P','04/02/2006','PL','N',25); INSERT INTO PLUCK VALUES ('022006', 'A01693P','05/02/2006','LH','N',0);
Dear All,Can we do multiple result row as a single row while selection ..?Request you to provide the SQL if we can achieve this...For Eg,Table Name = Employeeid - EmployeeName - addresstype - address1 - address2 - City1 - AAA - permanent - 231 - First Street - XYA2 - AAA - Temporary - 343 - Second Street - XYAExpecting Result as a Single row as below,id - EmployeeName - Address1 - Address21 - AAA - 231/First Street/XYA - 343/Second Street/XYAThanks in advanceRgds,Ganapathi sundaram.G
Hello,Is there a way to merge the result of a query into one row?For example, let say I want the a list of name of people of 20 year soldMy result will look like that: NAME1 john2 Mike3 Craig I would like to have the result in one row: NAME1 John, Mike, CraigIs there a way to do that?Thanks
Dear Experts Here is my code: SqlConnectioncn = new SqlConnection(ConfigurationManager.ConnectionStrings["SimvipConnectionString"].ConnectionString); protected void Page_Load(object sender, EventArgs e) { SqlCommand cmd = new SqlCommand("SP_SEARCH", cn); cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.Add(new SqlParameter("@TypeOfSim", Request.QueryString["NID"])); cmd.Parameters.Add(new SqlParameter("@CategoryID", Request.QueryString["CID"])); cmd.Parameters.Add(new SqlParameter("@Price", Request.QueryString["L"])); cmd.Parameters.Add(new SqlParameter("@Price2", Request.QueryString["S"])); cmd.Parameters.Add(new SqlParameter("@Title", Request.QueryString["keyword"])); cmd.Connection.Open(); cmd.ExecuteNonQuery(); SqlDataAdapter sqlAdapter1 = new SqlDataAdapter(); sqlAdapter1.SelectCommand = cmd; DataSet ds = new DataSet(); sqlAdapter1.Fill(ds, "ds");
CollectionPager1.DataSource = ds.Tables["ds"].DefaultView; CollectionPager1.BindToControl = DataList1; DataList1.DataSource = CollectionPager1.DataSourcePaged; } My problem is when there is no result(no item in database), the DataList1 will display the text "some text will display here" instead of empty page. In FormView I know the option <EmptyDataTemplate>. But in the DataList I don't know how to do this. I am a beginner. Can anybody show me how....Thanks a lots
I have an account field which has datatype string. I want to only get those values which are in between 0-199. I used select sum(t.a_trans_amt) Credit from a_account a, a_transaction t where a.a_account_num between '0' and '199'and t.a_account_id=a.a_account_id and t.a_debit_credit_ind='C'but this query also including those values which have starting 3 digit in between 0-199. I don't know how to fix this problem . Can anybody help me on this issue. Thanks in Advance.