February 21, 2014 at 6:53 am
Hello Friends,
I just got struck while building a query with sql in ms acess
I want to minus two rows in sql with ID as 2 and 3 and want the output of the conversion values in a new column
COS_IDCUR_DATECUR_RATEVCOS_NAMEVCOS_QUOTA_OLDconversion
116.07.2013 7,86MCR_P_OLD 100% 0
216.07.2013 1,31ST_P_OLD 100% 381,888
316.07.2013 1OFR_P_NEW 100% 230
116.07.2013 7,86MCR_P_OLD 100% 0
216.07.20131,31ST_P_OLD100%54,6
316.07.20131OFR_P_NEW100%14
116.07.20137,86MCR_P_OLD100%0
216.07.20131,31ST_P_OLD100%51,285
316.07.20131OFR_P_NEW100%15,75
Now i have the table above and i want to minus the conversion values of(conversion(2 and 3) and want to display it in new column as i have 1,2,3 repeated values in COS_ID i want to the output like
COS_ID Conversion
2and3 381,888- 230 and the value should be in new column
Waiting for some response ASAP
Thanking you in advance
February 21, 2014 at 7:13 am
dannayakrahul (2/21/2014)
I just got struck while building a query with sql in ms acess
I want to minus two rows in sql with ID as 2 and 3 and want the output of the conversion values in a new column
COS_IDCUR_DATECUR_RATEVCOS_NAMEVCOS_QUOTA_OLDconversion
116.07.2013 7,86MCR_P_OLD 100% 0
216.07.2013 1,31ST_P_OLD 100% 381,888
316.07.2013 1OFR_P_NEW 100% 230
116.07.2013 7,86MCR_P_OLD 100% 0
216.07.20131,31ST_P_OLD100%54,6
316.07.20131OFR_P_NEW100%14
116.07.20137,86MCR_P_OLD100%0
216.07.20131,31ST_P_OLD100%51,285
316.07.20131OFR_P_NEW100%15,75
Now i have the table above and i want to minus the conversion values of(conversion(2 and 3) and want to display it in new column as i have 1,2,3 repeated values in COS_ID i want to the output like
COS_ID Conversion
2and3 381,888- 230 and the value should be in new column
Waiting for some response ASAP
Thanking you in advance
Please say me is it possible to do i sql or not as iam not that good in sql need your Suggestion too
February 21, 2014 at 7:42 am
Hi and welcome to the forums. It is really difficult to figure out what you are trying to do here. You should take a few minutes and read the first article in my signature for best practices when posting questions.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
February 22, 2014 at 7:57 am
Hello,
Thank you for your response i dont know exactly how to develop a query to that problem that is why i have kept the question with some practical data please help me out for my question
February 23, 2014 at 8:04 pm
Hi
I would like to understand your data a little better before attempting to advise you on the query to solve your problem.
The data seems to include a repeating group of IDs 1, 2 and 3. IDs 1 and 2 seem to be OLD, while ID 3 is new. Is this a consistent pattern?
Cheers
February 24, 2014 at 7:29 am
dannayakrahul (2/22/2014)
Hello,Thank you for your response i dont know exactly how to develop a query to that problem that is why i have kept the question with some practical data please help me out for my question
I take it you didn't actually read my response or the article I suggested?
In order to help we will need a few things:
1. Sample DDL in the form of CREATE TABLE statements
2. Sample data in the form of INSERT INTO statements
3. Expected results based on the sample data
Please take a few minutes and read the first article in my signature for best practices when posting questions.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
February 24, 2014 at 10:00 am
dannayakrahul (2/22/2014)
Hello,Thank you for your response i dont know exactly how to develop a query to that problem that is why i have kept the question with some practical data please help me out for my question
If I were to take your sample data and create a table with it, I could then list this table and there is no guarantee that the rows would occur in the same order, so you need to provide some criteria on how we determine which two rows to combine to produce the new output. As it is, there is no way to ensure that this table will list as contained in your post unless we just assume we're going to get lucky.
What you could do is also include as the very first column an explicit integer ordering of your data, or some other value that we could sort by.
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply