473,396 Members | 1,749 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Kindly Help.

i have 2 columns in a table

ED EF
(numeric) (numeric(7,4))

1 44.23
2 55.39
3 44.25
4 33.78

the outut should be displayed as

col1 col2 col3 col4 col5
1 44.23 2 55.39 difference of col2 and col4
2 55.39 3 44.25 difference of col2 and col4...

and same for other values..

How do i display output in this format.
Kindly help.
Dec 25 '06 #1
1 934
ronverdonk
4,258 Expert 4TB
Strictly speaking this post belongs in one of the SQL forums. I will, however, reply to it here.

I have tested this using MySQL. This solution will only work under the following strict conditions:

1. the difference between each pair of consecutive ED fields is always 1!
2. you need 2 views to address the intermediate results.
Expand|Select|Wrap|Line Numbers
  1. CREATE VIEW v1 AS SELECT * FROM t WHERE ED%2 > 0;
  2. CREATE VIEW v2 AS SELECT * FROM t WHERE ED%2 = 0;
  3. SELECT v1.ED as Col1,v1.EF as Col2, 
  4.     v2.ED as Col3, v2.EF as Col4, 
  5.     v1.EF-v2.EF AS Col2minusCol4 
  6.     FROM v1 JOIN v2 
  7.     WHERE v1.ED+1 = v2.ED;
The result of this on your sample is
Expand|Select|Wrap|Line Numbers
  1. +------+---------+------+---------+---------------+
  2. | Col1 | Col2    | Col3 | Col4    | Col2minusCol4 |
  3. +------+---------+------+---------+---------------+
  4. |    1 | 44.2300 |    2 | 55.3900 |      -11.1600 |
  5. |    3 | 44.2500 |    4 | 33.7800 |       10.4700 |
  6. +------+---------+------+---------+---------------+
Ronald
Dec 25 '06 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: muralidharan | last post by:
WebForm1.aspx Code: <%@ Register TagPrefix="ComponentArt" Namespace="ComponentArt.Web.UI" Assembly="ComponentArt.Web.UI" %> <ComponentArt:TreeView id="TreeView1" Height="520"...
2
by: CM | last post by:
Hi, Could anyone please help me? I am completing my Master's Degree and need to reproduce a Webpage in Word. Aspects of the page are lost and some of the text goes. I would really appreciate it....
2
by: amily | last post by:
Hi All, I made a page in asp.net to edit information in the database using gridviewcontrol. It was working fine. Then i entered the template column having dropdown list. now the page opens and and i...
1
by: Chris | last post by:
Hi, I am working on a small which involves a touchscreen and I need to create a on-screen keyboard. I need some assistance with a few questions 1. For the the buttons, do I user their text as...
0
by: subramanian100in | last post by:
I have given below the structures and the function that finds the height of a BST by iteration. I have tested the function for several input sets and it is working. Kindly review the code and...
11
by: Siddhu | last post by:
Hai, i am student & i have struck up with the following program's output. Kindly help me to reason out why the output goes as which is given below. THE PROGRAM goes as; #include<iostream.h>...
0
by: cmrhema | last post by:
Hello, I have converted reading xls to sqlserver successfully. Here's the code. Now I want slight modification in the below lines, I do not want the values Created By and Created Date from...
1
by: cmrhema | last post by:
Hi, I wrote the following code in the page load event string path = clientServerXRef1.GetDownloadpath(company.ToUpper()); System.IO.FileStream fs = null; fs =...
3
sreekandank
by: sreekandank | last post by:
I want to implement POP3 program in java....I have written the code like... import javax.mail.*; import javax.mail.internet.*; import java.util.*; import java.io.*; public class POP3Client {...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.