Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Please help me in solving this problem building a sql query in MS acess Expand / Collapse
Author
Message
Posted Friday, February 21, 2014 6:53 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, May 26, 2014 8:00 AM
Points: 3, Visits: 14
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_ID CUR_DATE CUR_RATE VCOS_NAME VCOS_QUOTA_OLD conversion
1 16.07.2013 7,86 MCR_P_OLD 100% 0
2 16.07.2013 1,3 1ST_P_OLD 100% 381,888
3 16.07.2013 1 OFR_P_NEW 100% 230
1 16.07.2013 7,86 MCR_P_OLD 100% 0
2 16.07.2013 1,3 1ST_P_OLD 100% 54,6
3 16.07.2013 1 OFR_P_NEW 100% 14
1 16.07.2013 7,86 MCR_P_OLD 100% 0
2 16.07.2013 1,3 1ST_P_OLD 100% 51,285
3 16.07.2013 1 OFR_P_NEW 100% 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
Post #1543951
Posted Friday, February 21, 2014 7:13 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, May 26, 2014 8:00 AM
Points: 3, Visits: 14
[quote]dannayakrahul (2/21/2014)
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_ID CUR_DATE CUR_RATE VCOS_NAME VCOS_QUOTA_OLD conversion
1 16.07.2013 7,86 MCR_P_OLD 100% 0
2 16.07.2013 1,3 1ST_P_OLD 100% 381,888
3 16.07.2013 1 OFR_P_NEW 100% 230
1 16.07.2013 7,86 MCR_P_OLD 100% 0
2 16.07.2013 1,3 1ST_P_OLD 100% 54,6
3 16.07.2013 1 OFR_P_NEW 100% 14
1 16.07.2013 7,86 MCR_P_OLD 100% 0
2 16.07.2013 1,3 1ST_P_OLD 100% 51,285
3 16.07.2013 1 OFR_P_NEW 100% 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
Post #1543962
Posted Friday, February 21, 2014 7:42 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 2:34 PM
Points: 12,923, Visits: 12,342
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 Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1543994
Posted Saturday, February 22, 2014 7:57 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, May 26, 2014 8:00 AM
Points: 3, Visits: 14
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
Post #1544246
Posted Sunday, February 23, 2014 8:04 PM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Monday, July 21, 2014 4:34 PM
Points: 48, Visits: 9,470
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
Post #1544340
Posted Monday, February 24, 2014 7:29 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Yesterday @ 2:34 PM
Points: 12,923, Visits: 12,342
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 Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1544517
Posted Monday, February 24, 2014 10:00 AM
Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Yesterday @ 6:24 AM
Points: 341, Visits: 2,451
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.
Post #1544622
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse