473,385 Members | 1,536 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,385 software developers and data experts.

Need SQL Query: produce output of 100s, 1000s, etc. based on table data

20
Hi Everyone,
Here i need your help, and this is my table


Expand|Select|Wrap|Line Numbers
  1. CREATE TABLE cont (contnumber VARCHAR2(10), rcptnum NUMBER, rcptamount NUMBER);
  2.  
  3. INSERT INTO cont
  4.             (contnum, rcptnum, rcptamt
  5.             )
  6.      VALUES ('a123', 1, 120
  7.             );
  8. INSERT INTO cont
  9.             (contnum, rcptnum, rcptamt
  10.             )
  11.      VALUES ('a123', 2, 260
  12.             );
  13. INSERT INTO cont
  14.             (contnum, rcptnum, rcptamt
  15.             )
  16.      VALUES ('a123', 3, 300
  17.             );
  18. INSERT INTO cont
  19.             (contnum, rcptnum, rcptamt
  20.             )
  21.      VALUES ('a123', 4, 380
  22.             );
  23. INSERT INTO cont
  24.             (contnum, rcptnum, rcptamt
  25.             )
  26.      VALUES ('q123', 1, 1000
  27.             );
  28. INSERT INTO cont
  29.             (contnum, rcptnum, rcptamt
  30.             )
  31.      VALUES ('q123', 2, 1500
  32.             );
  33. INSERT INTO cont
  34.             (contnum, rcptnum, rcptamt
  35.             )
  36.      VALUES ('q123', 3, 2000
  37.             );
  38. INSERT INTO cont
  39.             (contnum, rcptnum, rcptamt
  40.             )
  41.      VALUES ('q123', 4, 3500
  42.             );
  43. INSERT INTO cont
  44.             (contnum, rcptnum, rcptamt
  45.             )
  46.      VALUES ('z123', 1, 150000
  47.             );
  48. INSERT INTO cont
  49.             (contnum, rcptnum, rcptamt
  50.             )
  51.      VALUES ('z123', 2, 220000
  52.             );
  53. COMMIT ;
I Want The Output In SQL,

Expand|Select|Wrap|Line Numbers
  1.     contnumber   rcptamount
  2.      a123         100
  3.      a123         200
  4.      a123         300
  5.      q123         1000
  6.      q123         2000
  7.      q123         3000
  8.      z123         100000
  9.      z123         200000

That mean if 'rcptamount' in 100s, it should show as 100 ,200,300, if rcptamount in 1000s ,
it should show as 1000,2000,3000,if it is in lakhs ,it should be, 100000,200000 .
Please suggest me if there is any way in SQL.
I want like this ,take one 'contnum' for example,

Expand|Select|Wrap|Line Numbers
  1.     contnum | rcptnum | rcptamt
  2.     -----------------------------
  3.     a123     | 1      | 120 
  4.     a123     | 2      | 130
  5.     a123     | 3      | 180
  6.  
a123 'Contnum' having Three 'rcptnum' 1,2 and 3. those 'rcptamt' in 100s like 120,130 and 180.
the contnum a123 having rcptamts in 100s,
so i need to display as

Expand|Select|Wrap|Line Numbers
  1. contnum | rcptamt
  2. ----------------
  3. a123    | 100


Thank You.
Apr 29 '13 #1
1 1218
Rabbit
12,516 Expert Mod 8TB
I don't use oracle but I can give you the algorithm I would use.

1) Convert to a string if necessary. Some SQL engines require this, some do it automatically.

2) Take the first left character.

3) Append zeroes for the length of the string minus one.

4) Take the distinct of the results.
Apr 29 '13 #2

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

Similar topics

1
by: Rama S | last post by:
Hi, We need a query which retrieves option_code, for a plan from OPTION table which are unique in (market, "ALL"). I have an example below PLAN MARKET OPTION_CODE RATE...
0
by: PenBlast | last post by:
I need a SQL query that will return row1 and 2. The rule would be "2 (and only 2) occurences of Store_Number where Forms_Count is not the same. Store_Number Forms_count 3 5 3 ...
1
by: bmoos1 | last post by:
I need to make a Report of all people starting in 2004 by "Date Requested". Dates are entered as mm/dd/yyyy. I have a query that has all the people that started in 2004, but there are numerous...
1
by: write2ashokkumar | last post by:
hi.. i have query like this.. select id,name from tbl where id in(5,2,4,1,3); When i execute the above query.. i get the result set with ascending order by id by default....
2
by: jennk | last post by:
i am working in Access 97, our database tables are linked from ODBCsqlsvr (not even sure what that means). i have a table where each record has a unique customer and their order information. there...
2
by: Terry Olsen | last post by:
I have two tables each with one column of serial numbers. I need a query that will return only the serial numbers from Table1 that aren't in Table2. I need it to also return the serial numbers from...
1
by: write2ashokkumar | last post by:
hi... i have the table like this, Table Name : sample Total Records : 500000 (Consider like this) Sample Records: id ------------ name
1
by: write2ashokkumar | last post by:
hi... i have the table like this, Table Name : sample Total Records : 500000 (Consider like this) Sample Records: ----------------
1
by: write2ashokkumar | last post by:
hi... i have the table like this, Table Name : sample Total Records : 500000 (Consider like this) Sample Records: ----------------
1
by: karuppiah | last post by:
Hi All, i need query,how to select last 3 month ,last 3wek,last 3 days , this last 3 month and 3 week should be friday, using sysdate from dual table, there is no exsting table, pls any one help...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.