SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Please help me in solving this problem building a sql query in MS acess


Please help me in solving this problem building a sql query in MS acess

Author
Message
dannayakrahul
dannayakrahul
Forum Newbie
Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: General Forum Members
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
dannayakrahul
dannayakrahul
Forum Newbie
Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: General Forum Members
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
Sean Lange
Sean Lange
One Orange Chip
One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)

Group: General Forum Members
Points: 27208 Visits: 17557
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.

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)
dannayakrahul
dannayakrahul
Forum Newbie
Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: General Forum Members
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
ProofOfLife
ProofOfLife
SSC-Enthusiastic
SSC-Enthusiastic (110 reputation)SSC-Enthusiastic (110 reputation)SSC-Enthusiastic (110 reputation)SSC-Enthusiastic (110 reputation)SSC-Enthusiastic (110 reputation)SSC-Enthusiastic (110 reputation)SSC-Enthusiastic (110 reputation)SSC-Enthusiastic (110 reputation)

Group: General Forum Members
Points: 110 Visits: 9474
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
Sean Lange
Sean Lange
One Orange Chip
One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)One Orange Chip (27K reputation)

Group: General Forum Members
Points: 27208 Visits: 17557
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.

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)
patrickmcginnis59 10839
patrickmcginnis59 10839
SSCommitted
SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)

Group: General Forum Members
Points: 1864 Visits: 5527
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.

to properly post on a forum:
http://www.sqlservercentral.com/articles/61537/
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search