Number sequence for the value in the column group
I need to create a sequnece number in a column from 5, and incrementing 5, based on the presenet values in the first column. If the value in the first column changes then the sequence would start with 5 and an increment of 5.for example: I want to generate the following output
Cat_code Seq_No
1001 5
1001 10
1001 15
1001 20
5 2001
10 2001
15, 2001
3001 5
10-3001
4001 5
4001 10
4001 15
4001 20
5001 5
6001 5
5 7001
7001 10
7001 15
7001 20
7001-25
So if the cat_code changes, the sequence number should still start at 5 and should be to generate the sequence number until the cat_code changes again.
any help apreciated.
Thank you
Rahul
Hi, Rahul,
You can use the analytical function of the ROW_NUMEBR to generate the numbers, like this:
SELECT cat_code
, 5 * ROW_NUMBER () OVER ( PARTITION BY cat_code
ORDER BY NULL
) AS seq_no
FROM table_x
ORDER BY cat_code
, seq_no
;
You must use an ORDER byclause of Analytics when you call ROW_NUMBER. If you don't really care the order, so you can ORDER BY a constant, but you still need the analytical ORDER BY clause.
Tags: Database
Similar Questions
-
ORA-01438: value larger than the precision specified for the column '
When inserting the different entries of cheaper products in this table PF_PRODUCT_VIEWS_PROFILE, I'm having this problem of "java.sql.SQLException: ORA-01438: value larger than the precision specified for the column '.»
As I see it in the tables (desc pf4. PF_PRODUCT_VIEWS_PROFILE; & PFCA4 of ESCR. DCS_PRICE_LEVEL;), I see the accuracy for the price of the table PF_PRODUCT_VIEWS_PROFILE as NUMBER (12.7) & accuracy for the price of the table DCS_PRICE_LEVEL as NUMBER (19.7). There is therefore a difference in precision 7 units for the price in the PF_PRODUCT_VIEWS_PROFILE table that is causing this problem. So that would be the solution.
Could you please post my comments, so that I can change the accuracy for the price of the PF_PRODUCT_VIEWS_PROFILE table.
Need to confirm other columns in the table PF_PRODUCT_VIEWS_PROFILE does not exceed their precision values before making this change.Hello
Ideally avoid data loss as you increase the length of the column as it really is. You have to worry about this in the case if you reduce the length. It is always better to be doubly sure, so also check other tables.
see you soon
VT
-
Determine a value for each record for the whole group
< < Sorry I pasted erroneous results earlier > >
Hello
I have a table (in production, join the many tables, but for simplicity, I created a table), which has a few related accounts grouped by ACCT_GRP_ID I have to write a SQL (not a PL/SQL), who should have all columns of this table and an extra column "FLAG". For GA_CD = BBC, FLAG must have a value of 'No Show', if the APP_DT of at least a recording with the group is less than the current year also all the records in the group will have a value of 'Show '. For the record no BBC FLAG must always be 'Show '.
DDLS
{code}
CREATE TABLE ACCOUNTS
(NUMBER OF ACCT_GRP_ID,
GA_CD VARCHAR2 (10),
AGNT_NAME VARCHAR2 (50).
NUMBER OF CASE_NUM
NUMBER OF FUND_AMT
DATE OF APP_DT,
STATUS VARCHAR2 (10));
INSERT INTO ACCOUNT VALUES (1, 'BBC', 'SAMANTHA, JOSE, 12345, 234.33, 2 AUG 2008', ' PLACED');
INSERT INTO ACCOUNT VALUES (1, 'BBC', 'SAMANTHA, JOSE, 12346, 331,13, 24 APR 2009', ' PLACED');
INSERT INTO ACCOUNT VALUES (1, 'BBC', 'SAMANTHA, JOSE, 12347, 201,27, 13 FEB 2009', ' PLACED');
INSERT INTO ACCOUNT VALUES (2, 'BBC', ' MARK, ROSS, 12348, 98.12, 31 MAY 2009', 'PLACE' ");
INSERT INTO ACCOUNT VALUES (2, 'BBC', ' MARK, ROSS, 12349, 121.00, 25 JUNE 2009', 'PLACE' ");
INSERT INTO ACCOUNT VALUES (2, 'BBC', 'BRAND, ROSS, 12350, 11.00, 27 JUNE 2009', 'CLOSED');
INSERT INTO ACCOUNT VALUES (3, 'BBC', "RAJ MALIK", 12351, 89.00, 31 DEC 2008', 'PLACED');
INSERT INTO ACCOUNT VALUES (3, 'BBC', "RAJ MALIK", 12352, 22.00, 26 OCT 2008', 'PLACED');
INSERT INTO ACCOUNT VALUES (4, 'BBC', 'SHANE, WILLS', 12353, 443.00, 7 JUNE 2009', 'PLACE');
INSERT INTO ACCOUNT VALUES (5, 'BBC', 'JANE, WALLACE, 12354, 74.00, 17 JAN 2009', ' PLACED');
INSERT INTO ACCOUNT VALUES (NULL, 'BBC', 'ROSY, BETH', 12355, 124.00, 21 MAR 2009', 'PLACE');
INSERT INTO ACCOUNT VALUES (NULL, 'STAR', 'TINA, WZWICK', 22330, 89.00, 31 DEC 2008', 'PLACED');
INSERT INTO ACCOUNT VALUES (NULL, 'STAR', 'YANA, KORVIN', 27351, 22.00, 26 OCT 2008', 'PLACED');
INSERT INTO ACCOUNT VALUES (NULL, 'STAR', 'SARA, YUI', 22352, 443.00, 7 JUNE 2009', 'PLACE');
INSERT INTO ACCOUNT VALUES (NULL, 'STAR', 'MIKE, TROY, 22453, 74.00, 17 JAN 2009', ' PLACED');
COMMIT;
{code}
Required result:
{code}
APP_DT GA_CD AGNT_NAME STATE BOITE_ FUND_ ACCT_ INDICATOR
AMT NUM GRP_ID
1 SAMANTHA, JOSE PLACE 12347 201.27 BBC 13/02/2009 no show
1 SAMANTHA, JOSE PLACE 12346 331.13 BBC 24/04/2009 no show
1 SAMANTHA, JOSE PLACE 12345 234.33 BBC 08/02/2008 no show
MD2 BBC BRAND, ROSS CLOSED 12350 11 6/27/2009 see the
MD2 BBC BRAND, ROSS PLACED 12349 121 6/25/2009 see the
2 BRAND of BBC, ROSS PLACE 12348 98.12 show of 31/05/2009
3 BBC RAJ MALIK not PLACED 12352 22 10/26/2008 no show
3 BBC RAJ MALIK not PLACED 12351 89 12/31/2008 no show
4 BBC SHANE, WILLS PLACE 12353 443 6/7/2009 see the
5 BBC JANE, WALLACE PLACE 12354 74 1/17/2009 see the
STARS of MIKE, TROY PLACED 22453 74 1/17/2009 see the
See the BBC ROSE, BETH PLACED 12355 124 3/21/2009
STAR SARA, YUI PLACED 22352 443 6/7/2009 see the
TINA, WZWICK STAR PLACED 22330 89 12/31/2008 see the
YANA STAR, KORVIN PLACED 27351 22 10/26/2008 see the
{code}
As in the results Group 1 has a record with the date of 2008 for the whole group getting 'No Show'. Group 2 has all the records this year, so he gets the 'Show '.
Help, please!
Published by: Kuul13 on June 25, 2009 13:31
Published by: Kuul13 on June 25, 2009 13:43
I think I'm really having a BAD BAD day... Sorry again... I don't need the domain TOT_FUND_AMT...Hello
Thanks for posting the DDL and DML statements. This helps a lot.
I don't understand the output, however. Do you want to really two rows of output for each row in the table? The tot_fund_amt is copied from somewhere else? More important still, the results do not include the new flag column. Isn't the point of all of this question? It's good to describe how the indicator is calculated, but you have to show, too.
I think you want analytical MIN function to find the first app_dt in each group, like this:
SELECT a.* , CASE WHEN ga_cd = 'BBC' AND MIN (app_dt) OVER ( PARTITION BY ga_cd , acct_grp_id ) < TRUNC (SYSDATE, 'YYYY') THEN 'No Show' ELSE 'Show' END AS flag FROM accounts a ;
Output:
. ACCT _GRP GA CASE FUND _ID _CD AGNT_NAME _NUM _AMT APP_DT STATUS FLAG ------ ---- --------------- ------ -------- ---------- ------ ------- 1 BBC SAMANTHA, JOSE 12345 234.33 08/02/2008 PLACED No Show 1 BBC SAMANTHA, JOSE 12346 331.13 04/24/2009 PLACED No Show 1 BBC SAMANTHA, JOSE 12347 201.27 02/13/2009 PLACED No Show 2 BBC MARK, ROSS 12348 98.12 05/31/2009 PLACED Show 2 BBC MARK, ROSS 12349 121.00 06/25/2009 PLACED Show 2 BBC MARK, ROSS 12350 11.00 06/27/2009 CLOSED Show 3 BBC RAJ, MALIK 12351 89.00 12/31/2008 PLACED No Show 3 BBC RAJ, MALIK 12352 22.00 10/26/2008 PLACED No Show 4 BBC SHANE, WILLS 12353 443.00 06/07/2009 PLACED Show 5 BBC JANE, WALLACE 12354 74.00 01/17/2009 PLACED Show BBC ROSY, BETH 12355 124.00 03/21/2009 PLACED Show STAR TINA, WZWICK 22330 89.00 12/31/2008 PLACED Show STAR SARA, YUI 22352 443.00 06/07/2009 PLACED Show STAR MIKE, TROY 22453 74.00 01/17/2009 PLACED Show STAR YANA, KORVIN 27351 22.00 10/26/2008 PLACED Show
Note that the NULL acct_grp_id is a group. PARTITION BY acct_grp_id is of course necessary, but we must also, PARTITION BY ga_cd all non-BBC lines will be included in this group. In other words, we are unwilling reported as 'No Show', all ROSY just because TINA or JANA had an early app_dt.
-
Replacement for the Working Group to el Capitan Manager?
I recently built new servers, intending using open directory.
The equipment I use are the new mac mini servers, with two 1 TB drives and 16 GB of memory.
Historically I have used Workgroup Manager for direct starting, deployment of the printer files, user groups and others.
Is there a replacement for the Working Group Manager who no longer works with el capitan (10.11.3)?
The replacement is the Manager of service profile. See the built-in help of server for instructions begin. This is beta-quality software, at best.
-
Adding a printer already installed on the pc for the home group network
I want to add a printer that is already installed on my computer for the home group network. Because it is already installed, it does not appear when the computer search possible printers to be added. I don't want to uninstall and reinstall - our relationship is much fragile. Help, please.
Hello
See if this helps you:
http://Windows.Microsoft.com/en-us/Windows/install-printer-home-network#1TC=Windows-7
Setting up a shared printer"The most common way to make a printer available to a home network is traditionally to connect to one of the computers and then tell Windows to share it. This is called a shared printer.
The advantage of sharing a printer is that it works with any USB printer. Side tilted? The host computer must always be fed up, otherwise the rest of the network will not be able to access the shared printer. »
________________________________
Homegroup: recommended links
http://Windows.Microsoft.com/en-us/Windows7/HomeGroup-recommended-links
Read this section:
'Connecting to homegroup printers' under ' access to files and printers on other computers in the homegroup.
http://Windows.Microsoft.com/en-us/Windows7/access-files-and-printers-on-other-HomeGroup-computers
See you soon.
-
Static value in the formula for the column
Hi all, I have a pretty simple question. How can you put a static value in a formula in the column? Just written a number does not work.You get the ODBC error because you are using the custom as a standalone field. Use in conjunction with any other field.
For example: If the test then use your number field and date. then in the design of pivot, put date (set to the Max aggregation) measures and your number in the sections. This will work. -
ODI 12 C | Error ORA-01438: value larger than the precision specified for the column
I keep getting this error when trying to load an XML file exchange rates in a table of data warehouse. I defined the type of XML data model to NUMBER (18,15), identical to the target and it works for rates with an accuracy of 1, then when the transformed with an accuracy of 4 it generates this error. This was really frustrating... There must be somewhere a temporary table created with precision different, right? Any help with this would be appreciated.
The example data:
Result of currency rates
1.4454325324 COL AUD
1.3943435826 CAD PASS
8.9824929424 COL CNY
4326.4323456123 COP FAIL
You seem to be confused with the terminology you use here. The precision is the total number of digits allowed in your number in your definition, i.e. NUMBER (18,15), precision 18, which means that you can have up to 18 digits in your number. However, you have also defined a scale value of 15 that denotes the amount of numbers that are sitting to the right of the decimal point. This means that you have only allowed for the 3 digits to sit to the left of the decimal point that is precision - scale (18-15). That's why you get the error when you try and load the COP currency that your definition of data type does not support having more than 3 digits left of the decimal separator.
-
using column value in a CSS Style for the column in the report
I am trying to apply a style CSS (background color) to a column in a report based on another column.
So the attributes column for a specific column, I would like to be able to add this to the "CSS Style" field under the group, "formatting of column:
background-color: #BKG_COLOR #;
It seems not to take my column value, which is #daf2ea
In the field of Style CSS, if I change it to: background-color: #daf2ea - so it works.
So he doesn't seem to take my #BKG_COLOR column value' in the field of Style CSS.
Any ideas? What do I have to use the "HTML Expression" field instead, and how could I do?
Thank you
Johnjfosteroracle wrote:
I am trying to apply a style CSS (background color) to a column in a report based on another column.So the attributes column for a specific column, I would like to be able to add this to the "CSS Style" field under the group, "formatting of column:
background-color: #BKG_COLOR #;
It seems not to take my column value, which is #daf2ea
In the field of Style CSS, if I change it to: background-color: #daf2ea - so it works.
So he doesn't seem to take my #BKG_COLOR column value' in the field of Style CSS.
Any ideas? What do I have to use the "HTML Expression" field instead, and how could I do?
Don't believe that * CSS Style * supports the substitution of the column.
You can use * HTML Expression: *
{code}
#OTHER_COLUMN #.
{code}
However the two this and * CSS Style * apply a style to a span element in the cell of the report, rather than the whole cell, which is what everyone expects in general / wants. To apply background color to the cell, you must use a custom report named column model: + {message identifier: = 9908585} +. -
How to create the presentation for the columns variable and use it in the story?
Hi all
Someone knows how to create variable presentation for a column (that is, I need to create it in edit section formula itself). And then, I should use it in the Narrative section to display the value of this column. Is this possible? Or do I need to use any other variable for this requirement? If Yes please let me know, how to create it? This is a very urgent requirement.
Thanks in advance
StephanieHello
You can have any number of columns in the narrative view, he will accept... Just mention the numbers of the columns in the view body narrative...check if useful/correct...
Thank you
prassu -
Change data type for the column in a table - Oracle 8i
Team,
I need to change a VARCHAR2 column in number.
ALTER table xyz change number abc;
By giving the above statement, it says I need empty this column before you change.
I can't change the data type before emptying this column.
Please indicate any other solution. Give me some suggestions.
Empty the column for me here BIG task.user11081688 wrote:
I can't change the data type before emptying this column.Not according to the documentation:
You can change the data type of any column or decrease the size of the entire column if all rows in the column contains NULL values.
Please indicate any other solution. Give me some suggestions.
You can add another column with the correct data type.
ALTER TABLE xyz ADD COLUMN def NUMBER; UPDATE TABLE xyz SET def = TO_NUMBER(abc); ALTER TABLE xyz DROP COLUMN abc; ALTER TABLE xyz ADD COLUMN abc NUMBER; UPDATE TABLE xyz SET abc = def; ALTER TABEL xyz DROP COLUMN xyz;
If I remember correctly, Oracle 8i does not support the change of name of column if this solution is a bit more complicated than 9i and above. Another option would be to create a new table with CREATE TABLE AS... SELECT, drop the old one and rename a new one to the old.
-
DB sequence for the primary key
Hello
I have Table of key primary we use DB sequence in the database itself, for example if start a line (using sql client) DB without primary key sequence will do it for me, because of this trigger.
(1) my doubt is if I generate A EO off this table I need to explicitly set db sequence for this attribute as this or no need to do this sequence bz DB does good for me!
(new oracle.jbo.server.SequenceImpl("SEQ_NAME",adf.object.getDBTransaction())).getSequenceNumber()
-
Hi Oracle Experts,
I have a difficult question . Lets say that I have two table with the same name, but these two tables come from two different databases with 2 different users.
A source database and the user SCOTT
Table Column Data_Type Length PRECISION Scale Primary key Nullable Default Comment BOOKS BOOK_ID Varchar2 4 - - 1 - - - ISBN_10 Varchar2 13
- - - Yes - - PRICE Number - 6 2 - Yes - - Target database B and user DAVID
Table Column Data_Type Length PRECISION Scale Primary key Nullable Default Comment BOOKS BOOK_ID Varchar2 20 - - 1 - - - PRICE Number - 6 2 - Yes - - TITLE Varchar2 50 - - - Yes - - What I want to do:
I want to get a query script that shows which columns need to edit, add and drop depends on the source table (make the necessary changes to make the columns in the Source table columns the same target table). No need to make any changes in the database do not want the query that must run to make these changes.
EXAMPLE: I was using under query to get the query create table EMP. But seeing the column information to create the column even for the other user is difficult:)
Select dbms_metadata.get_ddl ('TABLE', 'EMP') of double
Erhan_toronto wrote:
Is it possible to see the result like this:
ALTER table Target_table change BOOK_ID Varchar2 (4);
ALTER table Target_table add ISBN_10 Varchar2 (13), null;
ALTER table drop TITLE Target_table;
There are two simple ways to do so.
1. use free sql Oracle development tools
http://www.Oracle.com/technetwork/developer-tools/SQL-Developer/downloads/index.html
Simply select 'Tools - Diff of the database' and go through the menus
Here is an article from Oracle by Jeff Smith that shows how do
http://www.Oracle.com/technetwork/issue-archive/2012/12-Sep/o52sqldev-1735911.html
>
Quickly copy, compare and synchronize databases with Oracle SQL Developer.
>
2 use the DBMS_METADATA_DIFF package - see the commercial doc
http://docs.Oracle.com/CD/E11882_01/server.112/e22490/metadata_api.htm#BABIDHGE
>
Using the DBMS_METADATA_DIFF API to compare the metadata of the object
>
If you look at step 14 of this article, you will see the result of the use of COMPARE_ALTER:
>
14. compare the results by using the navigation API DBMS_METADATA_DIFF:
SQL > SELECT dbms_metadata_diff.compare_alter ('TABLE', 'TAB1', 'TAB2') FROM dual;
ALTER TABLE 'SCOTT '. "' TAB1 ' ADD ("MGR"NUMBER (4,0))
ALTER TABLE 'SCOTT '. "' TAB1 ' DROP ("JOB")
ALTER TABLE 'SCOTT '. "' TAB1 ' CHANGE ('ENAME' VARCHAR2 (20))
ALTER TABLE 'SCOTT '. "' TAB1 ' ADD A KEY ('EMPNO') PRIMARY AID INDEX
PCTFREE, INITRANS 10 2 STORAGE (INITIAL 16384 MINEXTENTS THEN 16384 1)
MAXEXTENTS 505 PCTINCREASE 50 FREELISTS 1 FREELIST GROUPS 1 USER_TABLES
(VALEUR PAR DÉFAUT) ACTIVATE ALTER TABLE "SCOTT" TAB1"AND RENAME"TAB2 ".1 selected line.
>
-
ORDER BY using for the column that is not in a select list of selection?
Hi all.
I have a selection list on an APEX at the apex.oracle.com page, and I would like to order by the value of the UnitOrder column.
The SQL is:
Of course, this code does not work. And since it's a selection list, I can't just add foodunit.unitorder to the SELECT statement. In addition, I can not get rid of the SEPARATE, because then for some reason, it tends to view an infinite amount of the same line...SELECT DISTINCT foodunit.name AS display_value, foodunit.foodunitid AS return_value FROM foodunit, food WHERE foodunit.foodid = :P18_FOODID ORDER BY foodunit.unitorder ASC;
Order by UnitOrder is that all units that start with gram, mg, ml, kg,... etc., will be shown on top of the selection list. All other units of food will be shown on the second place and so on.
The UnitOrder column contains 1 or 2 as the value. 1 is the value for all lines which should be displayed at the top of the list of selection, 2 is the value for the rest.
So, what I want, it's all the lines in which the UnitOrder is 1, are displayed on top of the selection list. Usually only 2 list items get displayed in the list of selection at a time, depending on what food item a user has selected. The selection list is then refined to certain lines that match the foodid etc etc...
If someone has an idea, I would be very happy to hear about it.I don't see a join between the tables of your foodunit and food. That would solve your problem of "endless amount"?
(you can omit the food table of your selection)
-
HP Support Assistant - telephone number incorrect for the Germany
Let's not the phone number indicated in HP Support Assistant for the Germany. Under the button 'Contact support' location Germany selected, 'call HP"indicates phone number 01805 65 21 80. This phone number no longer in service.
The right phone numbers are on http://www8.hp.com/de/de/contact-hp/phone-assist.html and in my case, it would be + 49 69 2999 3434 for support for portable computers.
I used the Feedback button in the HP Support Assistant to report the problem on the wrong telephone number.
HP Support Assistant version: 7.0.39.15
Configuration file version: 7.0.2395.1100
Mike
The about button / check for the latest version on HP Support Assistant version: 7.0.39.15 (running on the laptop of HP ENVY 15 TS) came back with the result that the latest version is already installed. I noticed that on the page of the driver for my laptop, this 7.3.35.20 Version sp62291.exe is available. Once I had downloaded and installed this new version, support for the Germany phone numbers appear correctly.
Mike -
Phone number Australian for the Activation Center.
Can someone please give me the phone number for activation of windows vista for the Australia. -I don't get the option in this procedure not to not shit http://support.microsoft.com/kb/950929 and therefore cannot put in place a list of phone numbers. Vista business 64 bit need activation...
Hi Aignome,
You can view the following items and see if it helps.
Microsoft Activation centers worldwide telephone numbers
Activation and registration of a Microsoft product
http://support.Microsoft.com/?LN=EN-AU
Hope this information is useful.
Maybe you are looking for
-
my iphone 6 s fall down and I live in Israel, so I can't take it to the store... I bought it in may 2016 in London and I saved the recive. I want an iphone replacement for-i don't want a screen shot I want to just add the extra money and replace all
-
Problems with iOS 9.3.4
Yesterday, I installed this update and I am not satisfied at all. The biggest problem is the storage, I have an iPhone 64GB 6 s and before the upgrade, there were 22, 5 GB of free, now I have 1 GB free and it only decreases. I deleted all my music (5
-
White screen but still can open the e-mail and work with.
Where e-mail is supposed to appear to the right, that it is not. Email is there and I can see on the lower right screen and I can open it and use it but cannot display in the blink of an eye. And, making it very difficult to work with.
-
Equium M50 - How to get down to the keyboard?
How to get off the keyboard?
-
HP Envy 15 t-j100: keyboard NOT working on HP Envy 15 t-j100 computer laptop
Hi all! I have a HP ENVY 15 t-j100 Quad Edition CTO Notebook PC (ENERGY STAR), and most recently updated Windows 10 Saturday (a set of recommended updates), and after parts of the update on my keyboard no longer works. The bottom three rows of keys w