Pulling on the first line with a value of repetition
HelloWe use the Oracle 11.1.
We have a table of postal codes.
We have several lines for each zip code because we have different areas that use the same zip code.
We want to reduce the lines of a line by zip code. But they said use they want to keep the fields that differ (neighborhood of the exodus).
Then they said "Just take the first value of each."
This code reduces the postcodes of a line by postal code, but as you can see I replaced the field with the name of the field values.
SELECT distinct ZIPCODE, CITY, STATE, COUNTY, AREACODE, 'CITYTYPE', CITYALIASABBREVIATION, 'CITYALIASNAME', LATITUDE, LONGITUDE, TIMEZONE, ELEVATION, COUNTYFIPS, DAYLIGHTSAVING, PREFERREDLASTLINEKEY, CLASSIFICATIONCODE,
MULTICOUNTY, STATEFIPS, 'CITYSTATEKEY', 'CITYALIASCODE', 'PRIMARYRECORD', CITYMIXEDCASE, 'CITYALIASMIXEDCASE', STATEANSI, COUNTYANSI
FROM zip_code
GROUP BY ZIPCODE, CITY, STATE, COUNTY, AREACODE, CITYTYPE, CITYALIASABBREVIATION, LATITUDE, LONGITUDE, TIMEZONE, ELEVATION, COUNTYFIPS, DAYLIGHTSAVING, PREFERREDLASTLINEKEY, CLASSIFICATIONCODE, MULTICOUNTY, STATEFIPS,
CITYALIASCODE, PRIMARYRECORD, CITYMIXEDCASE, STATEANSI, COUNTYANSI
order by zipcode;
How should I take either one record per postal code with the first value in these fields orHow should I take the first record for each zip code?
either way works for me.
Thank you
Hello
This is called a Query Top - N , and this is a way to do it:
WITH got_r_num AS
(
SELECT z.*
, ROW_NUMBER () OVER ( PARTITION BY zipcode
ORDER BY city
, ... -- add tie-breakers here
) AS r_num
FROM zip_code
)
SELECT * -- or list all columns except r_num
FROM got_r_num
WHERE r_num = 1
;
You can simply use MIN or MAX on the columns, as the line with the name of the minimum city do not lowest have area code or the longitude. The above method preserves the first line of each zip code intact, where the 'first': the first in order of aphabetic by the name of the city. If it is not unique, then you may want breakage to the analytical ORDER BY clause.
If you are deleting rows, you can use this in a NOT IN subquery. If you copy lines to a new table, you can use the query above in an INSERT statement.
Published by: Frank Kulash, March 18, 2011 12:40
I just see Polywog response:
Pollywog wrote:
You can use the rank or rownumber function...
If I understand the problem, you don't want to use RANK in this particular case. When there is equality, GRADE will assign 1 to all the contenders. I think the whole point of this thread is that you exactly want a #1 in each zip code, which is what ROW_NUMBER, but not RANK, guarantees.
Tags: Database
Similar Questions
-
Return the first line with a non-null value in a column
Hey there, gurus. Can someone give me a hand with this?
I have a table with six columns: Class_ID, Course_ID, start_date, Last_Name, First_Name, company. When our students take a class and will fill in an evaluation form, they fill in the Class_ID Last_Name First_Name, and Company. The Course_ID and Start_Date are filled automatically based on the Class_ID.
I am trying to generate a report that contains Class_ID, Course_ID and Start_Date, PLUS the value of the first not null in the column of company for a combination given to the three first columns. Here is my SQL that does not quite do the trick:
Select distinct c.class_id, c.course_id, c.start_date, p.company
class c, person p, student s
where substr (c.course_id, 1, 3) = "OBI".
and c.start_date > = SYSDATE-30
and c.class_id = s.class_id
and s.pid = p.pid
order start_date, company, class_id, course_id
At present, if in a given class, a student entered "CCCC" under the name of the company and another entry "Collin Co Comm Coll" and another between "Collin College", I would get three rows of this class when you use the SQL above. I want just one line. I don't really like which company names gets selected - one of them will be great for our needs. I just need to see a line for each class_id and single value that some students entered the area of the company. And I guess I have to say that if no student fills in the name of the company I need to see the value null, because I need to see the line no matter what.
Looks like some sort of funky outer join or a coalesce, but it is beyond my ability to understand.
Now I get this:
During class 1234 SQL271 Date 22/07/2013 company XYZ Inc.
Made up of class 1234 SQL271 Date 22/07/2013 company XYZ
1234 SQL271 Date 22/07/2013 company XYZ, class
What I want:
Class 1234 SQL271 22/07/2013 Date course XYZ Inc. or one of the other 2
Thanks in advance!select c.class_id, c.course_id, c.start_date, max(p.company) company from class c, person p, student s where substr(c.course_id,1,3) = 'OBI' and c.start_date >= SYSDATE-30 and c.class_id = s.class_id and s.pid = p.pid group by c.class_id, c.course_id, c.start_date order by class_id, start_date, course_id
Or if you want to list all businesses, you can use LISTAGG if you're on the latest version of ORACLE
-
Mr President.
My worm jdev is 12.2.1
How to enter two rows at the same time with different default values that only the first line to use see?
Suppose I have a table with four fields as below
"DEBIT" VARCHAR2(7) , "DRNAME" VARCHAR2(50), "CREDIT" VARCHAR2(7) , "CRNAME" VARCHAR2(50),
Now I want that when I click on a button (create an insert) to create the first line with the default values below
So if I click on the button and then validate the second row with different values is also inserted on commit.
The value of the second row are like the picture below
But the second row should be invisible. It could be achieved by adding vc in the vo.
The difficult part in my question is therefore, to add the second row with the new default values.
Because I already added default values in the first row.
Now how to add second time default values.
Concerning
Mr President
I change the code given by expensive Sameh Nassar and get my results.
Thanks once again dear Sameh Nassar .
My code to get my goal is
First line of code is
protected void doDML(int operation, TransactionEvent e) { if(operation != DML_DELETE) { setAmount(getPurqty().multiply(getUnitpurprice())); } if (operation == DML_INSERT ) { System.out.println("I am in Insert with vid= " + getVid()); insertSecondRowInDatabase(getVid(),getLineitem(),"6010010","SALES TAX PAYABLE", (getPurqty().multiply(getUnitpurprice()).multiply(getStaxrate())).divide(100)); } if(operation == DML_UPDATE) { System.out.println("I am in Update with vid= " + getVid()); updateSecondRowInDatabase(getVid(), (getPurqty().multiply(getUnitpurprice()).multiply(getStaxrate())).divide(100)); } super.doDML(operation, e); } private void insertSecondRowInDatabase(Object value1, Object value2, Object value3, Object value4, Object value5) { PreparedStatement stat = null; try { String sql = "Insert into vdet (VID,LINEITEM,DEBIT,DRNAME,AMOUNT) values " + "('" + value1 + "','" + value2 + "','" + value3 + "','" + value4 + "','" + value5 + "')"; stat = getDBTransaction().createPreparedStatement(sql, 1); stat.executeUpdate(); } catch (Exception e) { e.printStackTrace(); } finally { try { stat.close(); } catch (Exception e) { e.printStackTrace(); } } } private void updateSecondRowInDatabase(Object value1, Object value5) { PreparedStatement stat = null; try { String sql = "update vdet set AMOUNT='"+ value5+"' where VID='" + value1 + "'"; stat = getDBTransaction().createPreparedStatement(sql, 1); stat.executeUpdate(); } catch (Exception e) { e.printStackTrace(); } finally { try { stat.close(); } catch (Exception e) { e.printStackTrace(); } } }
Second line code is inside a bean method
public void addNewPurchaseVoucher(ActionEvent actionEvent) { // Add event code here... BindingContainer bindings = BindingContext.getCurrent().getCurrentBindingsEntry(); DCIteratorBinding dciter = (DCIteratorBinding) bindings.get("VoucherView1Iterator"); RowSetIterator rsi = dciter.getRowSetIterator(); Row lastRow = rsi.last(); int lastRowIndex = rsi.getRangeIndexOf(lastRow); Row newRow = rsi.createRow(); newRow.setNewRowState(Row.STATUS_NEW); rsi.insertRowAtRangeIndex(lastRowIndex +1, newRow); rsi.setCurrentRow(newRow); BindingContainer bindings1 = BindingContext.getCurrent().getCurrentBindingsEntry(); DCIteratorBinding dciter1 = (DCIteratorBinding) bindings1.get("VdetView1Iterator"); RowSetIterator rsi1 = dciter1.getRowSetIterator(); Row lastRow1 = rsi1.last(); int lastRowIndex1 = rsi1.getRangeIndexOf(lastRow1); Row newRow1 = rsi1.createRow(); newRow1.setNewRowState(Row.STATUS_NEW); rsi1.insertRowAtRangeIndex(lastRowIndex1 +1, newRow1); rsi1.setCurrentRow(newRow1); }
And final saveUpdate method is
public void saveUpdateButton(ActionEvent actionEvent) { // Add event code here... BindingContainer bindingsBC = BindingContext.getCurrent().getCurrentBindingsEntry(); OperationBinding commit = bindingsBC.getOperationBinding("Commit"); commit.execute(); OperationBinding operationBinding = BindingContext.getCurrent().getCurrentBindingsEntry().getOperationBinding("Commit"); operationBinding.execute(); DCIteratorBinding iter = (DCIteratorBinding) BindingContext.getCurrent().getCurrentBindingsEntry().get("VdetView1Iterator");// write iterator name from pageDef. iter.getViewObject().executeQuery(); }
Thanks for all the cooperation to obtain the desired results.
Concerning
-
Discover with function as datasource returns only the first line.
Hello
I created the following function to get the status of all the rules for the instances of SQL Server.
The data type of the function output has been configured as 'List of SQLInstanceRuleStatuss', where SQLInstanceRuleStatuss is the custom type, I created in the same module.
When I tested the function, it returns all instances of SQL Server with two other columns.
But when I try to create a view with the Rows property that is configured to use the feature, it returns only the first line:
sqlRules = new ArrayList();
queryStatement = server. QueryService.createStatement ("(DBSS_Instance)");
queryResult = server. QueryService.executeStatement (queryStatement);
for (it in queryResult.topologyObjects)
{
sqlRule is functionHelper.createDataObject ("westjet_mark_dev:SQLInstanceRuleStatus", "none", "test");.
sqlRule.instance = it;
sqlRule.ruleName = 'test rule name';
sqlRule.status = false;
sqlRules.add (sqlRule);
}
Return sqlRules;
Did I miss something?
Thank you
Mark
Mark,
I think I forgot something
sqlRule=functionHelper.createDataObject("westjet_mark_dev:SQLInstanceRuleStatus","none","test");
you create the test id
change your line of
sqlRule=functionHelper.createDataObject("westjet_mark_dev:SQLInstanceRuleStatus","none",null);
This should allow the creation of a single object in your loop for
-
How can I change the first line of the table to a header row if it contains PGF with tblHead tags
So far, I have the following text in a JavaScript:
If (tbl. FirstRowInTbl.FirstCellInRow.FirstPgf.PgfFmt.Name = "tblHead")
{
If (tbl. FirstRowInTbl.RowType = 1).
1 is Constants.FV_ROW_BODY
tbl. FirstRowInTbl.RowType = 0;
0 is Constants.FV_ROW_HEADING
on the other
continue;
}
on the other
continue;
It does not work. I'm not comfortable with tbl. FirstRowInTbl.FirstCellInRow.FirstPgf.PgfFmt.Name.
It is clearly wrong. How I would I want to determine the tag of the first paragraph of the first line?
Any help is very appreciated!
Thank you
Ruth
Ruth, here is a function that converts the body lines to the header of a table lines. Please let me know if you have any questions or comments. -Rick
#target framemaker var doc = app.ActiveDoc; // Set a variable for the selected table. var tbl = doc.SelectedTbl; // Convert the first body row to a heading row. bodyToHeadingRow (tbl, 1, doc); function bodyToHeadingRow (tbl, num, doc) { var row = 0; // Select the top "num" rows in the table. tbl.MakeTblSelection (0, num - 1, 0, tbl.TblNumCols - 1); // Push the current clipboard contents and cut the selected rows. PushClipboard (); doc.Cut (Constants.FF_CUT_TBL_CELLS); // Add "num" number of heading rows to the table. row = tbl.FirstRowInTbl; row.AddRows (Constants.FV_Heading, num); // Select the new heading rows. tbl.MakeTblSelection (0, num - 1, 0, tbl.TblNumCols - 1); // Paste the rows from the clipboard into the new heading rows. doc.Paste (Constants.FF_REPLACE_CELLS); // Restore the clipboard contents. PopClipboard(); }
-
How to display the line empty as a line with null values
Hi all
Pls advise me if it is possible to use a single query statement to display
Empty row (i.e. not a single return line) as a line with null values.
For example,.
Select the names of names_mst whose name = "sgasfgs".
Result:
Names of
=====
< null >Hello
If you desire to join external to double, as shown below, you still get at least a line of productionSELECT nm.names FROM dual LEFT OUTER JOIN names_mst nm ON nm.name='sgasfgs';
-
Problem with white - style commentary on the first line of the select statement.
SQL * more error? :
It seems that the parser does not like "-" at the end of the first line of the request.
I see this error "ORA-00936: lack of expression" or "ORA-00933: not correctly completed SQL command.
SQL * Plus costs number not the 2nd line when I do that.
If a space follows-, '-', I still get the error.
a single "-" at the end of the line is ignored and the query works
But, "-." will not get the error.
I think that I had this problem before on the inside in the middle of a procedure from PL/SQL package.
--
It is of course easy to avoid. Is this just a quirk or am I missing something?
-----
SQL * more: 9.0.1.4.0 output
Oracle Database 10 g Enterprise Edition release 10.2.0.3.0
---------------------------------------------- -- These provoke an error ---------------------------------------------- SQL select 'a' -- from dual; select 'a' - from dual * ERROR at line 1: ORA-00936: missing expression /* the -- is "-- " */ SQL select 'a','b','c' -- from dual; select 'a','b','c' - from dual * ERROR at line 1: ORA-00936: missing expression SQL select -- select 'a' from dual -- ; select - select 'a' from dual - * ERROR at line 1: ORA-00936: missing expression SQL select 'a' from dual -- ; select 'a' from dual - * ERROR at line 1: ORA-00933: SQL command not properly ended ---------------------------------------------- -- These are OK ---------------------------------------------- SQL select 'a' --. 2 from dual; ' - a Elapsed: 00:00:00.00 SQL select 2 'a' -- 3 from dual; ' - a ------- a single "-" at the end of the line is ignored, query works SQL select 'a' from dual - ; ' - a SQL
Actually, it's in the docs, but we rarely know.
>
Continuing a long SQL More control on additional lines *.
You can continue a long SQL * more command by typing a hyphen at the end of the line and press return. If you want, you can type a space before you type the hyphen. SQL * Plus displays a right angle (>) support as a prompt for each additional line (not in iSQL * more).For example:
SALARY $99 999 COLUMN FORMAT-
SECTION "WAGES."
Since SQL * Plus identifies the hyphen as a continuation character, entering a hyphen in a statement SQL is ignored by SQL * more. SQL * more does not identify the declaration as a SQL statement until after the treatment of entry has joined lines together and removed the hyphen. For example, enter the following:SELECT - 200
100 DOUBLE;
Returns the error:>
It only happens for the first line of a sql statement, because at that time there you are not in the edit buffer. And the order could still be a sql * more order and not a sql command.
Published by: Sven w. on August 7, 2009 16:51
-
Hi all
We use JDeveloper Studio Edition Version 12.1.3.0.0 and deployed on GlassFish Server Open Source Edition 3.1.2.2 (build 5) and connect to the SQLServer database.
We created a table ADF programming related to a SortableModel created programmatically to a bean.
We need to select and highlight the first row in the table just after making it to retrieve data based on the first line.
We tried the based on the following thread: How to call the bean support just after JSFF / page fragment loads? and a few other posts online, but it does not work very well.
W has created a hidden text in the bottom of the JSF model as follows:
< af:table varStatus = "rowStat" Summary = "table" value = "#{pageFlowScope.crudBean.dynamicTable.collectionModel} '"
Rows = "#{pageFlowScope.crudBean.dynamicTable.collectionModel.RowCount} '"
contentDelivery = 'immediate' var = 'row' rendered = 'true '.
Binding = "#{backingBeanScope.crudBackingBean.tasksTable} '"
selectionListener = "#{backingBeanScope.crudBackingBean.customListener} '"
"rowSelection ="single"id ="t1"partialTriggers =": pt_gr2 "columnStretching =" column: clmn0 ">
< af:forEach items = "#{pageFlowScope.crudBean.dynamicTable.columnNames}" var = 'name' varStatus 'vs' = > "
< af:column sortable = "true" sortProperty rowHeader = "#{name}" = "no style" headerText = "#{pageFlowScope.crudBean.dynamicTable.columnLabel [name]}" "
inlineStyle = "width: 100px;" ID = "clmn$ {vs.index}" >
< af:activeOutputText value = "#{row [name]}" id = "aot1" / >
< / af:column >
< / af:forEach >
< / af:table >
....
< af:outputText id = "hiddenOutputTextId" visible = "false" value = "#{backingBeanScope.crudBackingBean.afterPageLoad} '"
Binding="#{backingBeanScope.crudBackingBean.hiddenOutputText}"/ >
And we have added the code to the bean to support below:
public String getAfterPageLoad() {}
If (!.) {AdfFacesContext.getCurrentInstance () .isPostback ()}
selectFirstRowInTasksTable();
}
Return afterPageLoad;
}
public void selectFirstRowInTasksTable() {}
try {}
RKS RowKeySet = new RowKeySetImpl();
RowKeySet rksEmpty = new RowKeySetImpl();
Model CollectionModel = tasksTable.getValue ((CollectionModel));
ROWCOUNT int = model.getRowCount ();
If (rowcount > 0) {}
model.setRowIndex (0);
Key of the object = model.getRowKey ();
RKS. Add (Key);
tasksTable.setSelectedRowKeys (rks);
SelectionEvent selectEvent =
new SelectionEvent (tasksTable.getSelectedRowKeys (), rks, tasksTable);
selectEvent.queue ();
customListener (selectEvent); / / to retrieve data
AdfFacesContext.getCurrentInstance () .addPartialTarget (tasksTable);
}
} catch (Exception e) {}
}
}
I think that () selectEvent.queue; should work even without calling the customerListener, but it is not working in all cases.
What is the problem in my code?
Have you tried to bind property of 'selectedRowKeys' to selection configuration / bean there?
Something like:
public RowKeySet getSelectedRKS() { if (rks == null) { // make first record as selected // create RowKeySet and assign it to rks variable(where rks is variable defined in bean with some scope higher than request scope) } return rks; }
Dario
-
First line indent except the first line of a paragraph
Hello
I would create a paragraph style with a first line indent, with the exception of the first line, which I have no dash.
Attached an example of how I want it to look.
Best regards
Vincent
You need a second style to the first paragraph. Based on the other model and the withdrawal of first line value of 0.
-
Delete in af:table always remove the first line when using ExecuteWithParams
Hello world
I got a page with master form and af:table two details related to the master. When I'm trying to remove a line in an af:table of detail, it always removes the first line, any line, I selected before. The table has a single = rowSelection and the line is properly visually selected. I remove the line using a "delete hyperlink" on each line, but I first have to select the line. Delete called a bond (or a method at the bean by removing the current line of the iterator, I tried both, none of them work)
Links page has an ExecuteWithParams defining the correct ID to edit on the master of iterator and an InvokeExecuteWithParams the renderModel value. If I put the refresh condition zero and I hard-code an ID in the binding variable in the model, I am able to delete the selected line.
In addition, I don't know if this information is useful, but if I set the iterator to PPR ChangeEventPolicy, when I select a line, there always select the first line.
Any ideas what I could do wrong? Is this a bug?
I use JDev 11.1.1.7
Thank you
Guillaume
You can try creating a method in ApplicationModule for filter master records instead of executeWithParams?
Ashish
-
How can I get the first line of a paragraph style indent, but others not in withdrawal
I created a style of paragraph indented on the first line of each paragraph. In most of the books, at the start of the first line of a chapter, this line is not indented while the rest are. Is there a way to set up in InDesign CS3? Is the only way to make this work is to manually go out the tab at the start of each chapter?
2 paragraph styles.
1 paragraph style has no dash
2nd paragraph style has dash
set "next style" in 1st paragraph for paragraph 2e style style
the "next style" value in the style of paragraph 2 to "even".
Existing text.
Select all of the text
Right-click on the 1 paragraph style and select apply style then next style.
New text (typeing)
Start typing with the selected 1 paragraph style. When you press ENTER to start a new paragraph, the style will switch automatically to the 2nd paragraph style to what manually enable you return.
HTH
-mt
-
save after focus leaves cell saves only the first line
I want that every cell in a table to save when focus leaves the cell. It seems that any line I am on it will always save this value in the first row. After that, I think it seems to save the new value in the correct lines. How can ensure me that the relevant line is saving?
This is the code for my laptop...
< af:inputText value = "#{rank." Simple PublishedNotes}' = 'true '.
required = "#{bindings." CIsForRR.attrDefs.Notes.mandatory}.
columns = "#{bindings." CIsForRR.attrHints.Notes.displayWidth}.
Binding = "#{bindings_app_ci_RR.inputText5} '"
ID = "inputText5" lines = '10' autoSubmit = 'true '.
valueChangeListener = "#{bindings_app_ci_RR.save_notes_action} '"
Then my save_notes_action looks like this...
{} public void save_notes_action (ValueChangeEvent vce)
FacesContext ctx = FacesContext.getCurrentInstance ();
Bind ValueBinding = ctx.getApplication ().createvalueBinding("#{data}");
BindingContext, bc = bind.getValue (ctx) (BindingContext);
DC DCDataControl = bc.findDataControl("AppModuleDataControl");
AppModuleImpl am = (AppModuleImpl) dc.getDataProvider ();
ViewObject vo = am.findViewObject ("RR");
Line = vo.getCurrentRow ();
prints the value of vce and the attribute of the current name of the lines
String newVal = valueChangeEvent.getNewValue (m:System.NET.SocketAddress.ToString ());
row.setAttribute ("Notes", newVal);
am.getTransaction () .commit ();
Refresh();
}
My impressions always printed the first line of name.
Any help is appreciated! Thank you!That's because you manually make the change in your code:
String newVal = valueChangeEvent.getNewValue (m:System.NET.SocketAddress.ToString ());
row.setAttribute ("Notes", newVal);
am.getTransaction () .commit ();Why not use a table can be changed with the binding of the ADF and simply let ADF do all the work for you.
-
Pleazzz... help me put my record of the opening on the first line
I use this query inside my builder6 (oracle10g) report, but it is untimely return of output.
only when I give the start date of the report (: m_frm_date) as the opening date (op_date), the balance
the report that is stored in the table op_bal, happens correctly, with the first line, the opening balance.
later, when I try to run the same report giving other start dates, opening balance
line was traded to the second row. Please refer to the screenshot of my reports, for the best idea.
http://S640.Photobucket.com/albums/uu123/fairoozxp/?action=view & Current = EXPRPT.jpgselect op_date, TNO,OP_CODE,EI,withdrawal,deposit, sum(NVL(DEPOSIT,0)-NVL(WITHDRAWAL,0)) over (order by op_date,TNO) bal from ( select op_date, NULL TNO,null OP_CODE,NULL EI,withdrawal,deposit from ( select :M_FRM_DATE op_date, sum(withdrawal) withdrawal, sum(deposit) deposit from ( select :M_FRM_DATE op_date,sum(DECODE(EXPN_EI,'E',EXN_AMOUNT)) WITHDRAWAL, sum(DECODE(EXPN_EI,'I',EXN_AMOUNT)) DEPOSIT from EXPENSES_TXN, expense_master where exn_acnt_code = expn_code and exn_date < to_CHAR(:M_FRM_DATE,'dd/mm/yyyy') union all select op_date, null withdrawal, op_amount deposit from op_bal)) union all SELECT EXN_DATE, EXN_NO, EXN_ACNT_CODE, EXPN_EI, DECODE(EXPN_EI,'E',EXN_AMOUNT) WITHDRAWAL, DECODE(EXPN_EI,'I',EXN_AMOUNT) DEPOSIT FROM EXPENSES_TXN, EXPENSE_MASTER WHERE EXN_ACNT_CODE = EXPN_CODE and EXN_DATE between to_CHAR(:M_FRM_DATE,'dd/mm/yyyy') and to_CHAR(:M_UPTO_DATE,'dd/mm/yyyy')) order by op_DATE,tno / this is the actual for which report has to come; SQL> select * from op_bal; OP_COD OP_NAME OP_DATE OP_AMOUNT ------ ------------------ --------- ------------- OP0000 NATIONAL BANK 01-JAN-09 5000.000 *Date No.2* SQL> SELECT 2 EXN_DATE, 3 EXN_NO, 4 EXN_ACNT_CODE, 5 EXPN_EI, 6 DECODE(EXPN_EI,'E',EXN_AMOUNT) WITHDRAWAL, 7 DECODE(EXPN_EI,'I',EXN_AMOUNT) DEPOSIT 8 FROM EXPENSES_TXN, EXPENSE_MASTER 9 WHERE EXN_ACNT_CODE = EXPN_CODE 10 order by 1; EXN_DATE EXN_NO EXN_AC E WITHDRAWAL DEPOSIT --------- ------------- ------ - ------------- ------------- 01-MAR-09 2.000 AC0002 E 2000.000 10-MAR-09 7.000 AC0012 I 500.000 15-MAR-09 5.000 AC0007 E 15.000 20-MAR-09 8.000 AC0012 I 700.000 31-MAR-09 6.000 AC0008 E 30.000 01-APR-09 9.000 AC0013 I 250.000 07-APR-09 1.000 AC0001 E 200.000 09-APR-09 4.000 AC0011 E 35.000 09-APR-09 3.000 AC0003 E 50.000 9 rows selected.
http://S640.Photobucket.com/albums/uu123/fairoozxp/?action=view & Current = EXPRPT1.jpg
http://S640.Photobucket.com/albums/uu123/fairoozxp/?action=view & Current = EXPRPT2.jpg
much appreciated, tyvm.Hello
Is the problem that, when it is be a rank with exn_date =: m_frm_date, the line which represents the total front: m_frm_date sometimes appears after him?
If Yes, then you must add something to the ORDEER TO ensure that the total line comes first.
If NWT is NULL rfor only the total row, and then, as said to put, simply add 'NULLS FIRST' to "ORDER BY tno". Don't forget to do this as well in the analytical AGENDA BY:OVER (ORDER BY op_date, tno NULLS FIRST) AS bal
towards the beginning of your query and the result ORDER BY value at the end:
ORDER BY op_date, tno NULLS FIRST;
If reallly NWT can be null, you can create a new column (I'll call her sort_key) ust to distinguish the total line on the lines later. SELECT a literal 1 sort_key of ACE in the part of the UNION that created the total line, and then '2 AS sort_key' in the part of the UNION, who gets lines and after: m_frm_date:
SELECT op_date, tno, op_code, ei, withdrawal, deposit, SUM ( NVL (deposit, 0) - NVL (withdrawal, 0) ) OVER (ORDER BY op_date, sort_key, tno) AS bal FROM ( SELECT TO_DATE (:m_frm_date, 'dd/mm/yyyy') AS op_date, NULL AS tno, NULL AS op_code, NULL AS ei, withdrawal, deposit, 1 AS sort_key FROM ( -- Begin sub-query for expenses before :m_frm_date SELECT TO_DATE (:m_frm_date, 'dd/mm/yyyy') AS op_date, SELECT SUM (withdrawal) AS withdrawal, SUM (deposit) AS deposit FROM ( SELECT SUM (DECODE (expn_ei, 'E', exn_amount)) AS withdrawal, SUM (DECODE (expn_ei, 'I', exn_amount)) AS deposit FROM expenses_txn, expense_master WHERE exn_acnt_code = expn_code AND exn_date < TO_DATE (:m_frm_date, 'dd/mm/yyyy') UNION ALL SELECT NULL AS withdrawal, op_amount AS deposit FROM op_bal ) ) -- End sub-query for expenses before :m_frm_date UNION ALL SELECT exn_date, exn_no, exn_acnt_code, expn_ei, DECODE (expn_ei, 'E', exn_amount) AS withdrawal, DECODE (expn_ei, 'I', exn_amount) AS deposit, 2 AS sort_key FROM expenses_txn, expense_master WHERE exn_acnt_code = expn_code AND exn_date BETWEEN TO_DATE (:m_frm_date, 'dd/mm/yyyy') AND TO_DATE (:m_upto_date,'dd/mm/yyyy') ) ORDER BY op_date, sort_key, tno;
Be sure to use strings to represent DATEs. If: m_frm_date is a string, it must always be used with TO_DATE and TO_CHAR ever.
Never, send or even write, unformatted code.
During the validation of code on this site, type the 6 characters
{code}
(small letters only, inside curly braces) before and after the code for formatting, to keep the spacing. -
First character left in file by reading the first line in text file
When you use the function of reading text from a file file, I noticed that the 1st character is left in the file. I read the line correctly.
When adding a 2nd line this character is in the file.
Part vi code is attached.
Any ideas?
Thank you.
Elik
Can you attach a file of real data and tell us what you mean by "first character". The number of characters per line do you have?
Can you tell us what you see in the modified file and what you expect to see.
Everything seems good.
- Read you the first line and so the file pointer is just after the first line
- You set the size of the file at the end (seems unnecessary, because it does nothing). The file pointer is always right after the first line.
- You write the first line you read concatenated with a second line. It will be written on the current file pointer, i.e. after the existing line
- The first line is in the file twice, as planned.
Setting the file size to the 'end' on an existing file does not have something useful. If you want to set the position of the file instead?
Try to set the file position from and new data will be written at the beginning of the file.
-
Scan of a file only works on the first line
Hello
I'm new to Labview (see 8.6) and I'm running on this problem.
I use the Scan of a file to get a certain amount of information for the installation of test.txt. The data of the file looks like this:
AAA 1
BBB 2
REC 3
I noticed that the Scan of the file works for only the first line. Trying to get data that are not in the first line results in an error 85.
Any ideas? Thank you
It's all in what the scan of the file reads, and what is the next cgaracter in the file.
Your first analysis of the file reads up to but NOT including the first newline in the file.
The second read readings where the first reading was arrested and is expected to see 'B' as the next character, but sees the new line instead, and if the analysis fails. You must specify second reading formatted to await the return line.
You can do this by making the FIRST character of the format string space, that will tell it to expect a number any of charaters 'white space '.
Yo can indeed put a space at the beginning of the format string in your first analysis of the file and it will match with zero white space characters before you see the AAA. By doing this he also tolerate to see the spaces and tabs before your AAA or BBB identifiers.
Rod.
Maybe you are looking for
-
How do I enable the allow_url_fopen option
I use a word press plugin on my site which requires the directive allow_url_fopen is enabled. It is currently disabled. You you please activate it on my server so that it comes into force in all of my sites.
-
How can I get a new iPad Pro one Cameroon what does take to become a partner of apple in Cameroon
wwhat does take to become a partner with Apple
-
How can I activate my internal webcam?
I've tried everything! Someone help me please. I can't understand how to activate my internal webcam for the life of me. I have a laptop HP 2010 (not sure of the name of the template) However, I have an internal webcam and it is always turned OFF...
-
HP Photosmart Plus B210 series
Suddenly, my printer has stopped printing in black ink. The cartridge is full. It's already happened and I just cleaned everything and it started working again. This time, I cleaned it again, it printed one page and then arrested again to print.
-
Problem to access the configuration of System Protection settings
Separated from this thread. Tried to go to the system protection as described, but the option does not exist on my HP laptop. Can get to the system restore, but not to the part to set the amount of space to throw