Getting past days data based on DATE data type column
I am trying to extract last 2 days data using date data type column with below query,
select * from tbl
where col < col -2;
this is not showing me any data. please help where i am making mistake. guide please. thx
Hi,
When you say "last 2 days" do you mean the 48 hours right before run-time?
If so, you want to compare col to SYSDATE:
select *
from tbl
where col > SYSDATE - 2
and col <= SYSDATE
;If you mean the "last 2 days" before some other event, then replace SYSDATE with that date in both places above.
If you were trying
where col > col - 2then you should have been getting all rows that have a non-NULL col. If you were getting no results, then something is very wrong.
I hope this answers your question.
If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all the tables involved, and the results you want from that data.
If the results depend on when you run the query, then give a couple of different examples, with the run-time. for example "If I run this at 03:00:00 on July 1, 2012, then I should get ... but if I run ir at 15:00:00 on July 1, 2012, then the results should be ...".
Explain, using specific examples, how you get those results from that data.
Always say what version of Oracle you're using.
See the forum FAQ {message:id=9360002}
Similar Messages
-
Vendor Balance Report Day wise based on Posting date
Hi Guru's,
I am creating vendor balance reprot day wise based on posting date .
In my report i want to show TDS(With hold tax ) amount where can i get that field name how can retrive the data using bsik and bsak .
I Donot want to display reversal documents in the displaying list .How can i remove reversal entries .
Regards
Nandan.Hi Nandan,
check these tables:
A399
T059O
T059ZT
Regards,
Santosh Kumar M -
FM to get previous sunday date based on current date(SY-DATUM)
hi all,
Is there any function module to get the previous sunday date based on current date(sy-datum)?
Regards,
Kapil SharmaHi Kapil,
You can follow the logic below:
data:
l_date like sy-datum, **TODAY
l_date2 like sy-datum, **Previous Sunday
data:
l_daynr like HRVSCHED-DAYNR.
*Get today's date
l_date = sy-datum.
*Gey today's day (Monday, Tuesday, etc.)
CALL FUNCTION 'HRIQ_GET_DATE_DAYNAME'
EXPORTING
langu = 'EN'
date = l_date
IMPORTING
daynr = l_daynr.
CASE l_daynr.
*If it is Monday
WHEN 1.
-Subtract 2 days for the previous Sunday
CALL FUNCTION 'HR_SEN_CALE_DAYS_DATE'
EXPORTING
id_date = l_date
id-operator = '-'
is_duration = 2
IMPORTING
ed_date = l_date2.
*If it is Tuesday
WHEN 2.
CALL FUNCTION 'HR_SEN_CALE_DAYS_DATE'
EXPORTING
id_date = l_date
id-operator = '-'
is_duration = 3
IMPORTING
ed_date = l_date2.
*If it is Wednesday
WHEN 3.
CALL FUNCTION 'HR_SEN_CALE_DAYS_DATE'
EXPORTING
id_date = l_date
id-operator = '-'
is_duration = 4
IMPORTING
ed_date = l_date2.
*If it is Thursday
WHEN 4.
CALL FUNCTION 'HR_SEN_CALE_DAYS_DATE'
EXPORTING
id_date = l_date
id-operator = '-'
is_duration = 5
IMPORTING
ed_date = l_date2.
*If it is Friday
WHEN 5.
CALL FUNCTION 'HR_SEN_CALE_DAYS_DATE'
EXPORTING
id_date = l_date
id-operator = '-'
is_duration = 6
IMPORTING
ed_date = l_date2.
*If it is Saturday
WHEN 6.
CALL FUNCTION 'HR_SEN_CALE_DAYS_DATE'
EXPORTING
id_date = l_date
id-operator = '-'
is_duration = 7
IMPORTING
ed_date = l_date2.
*If it is Sunday
WHEN 7.
CALL FUNCTION 'HR_SEN_CALE_DAYS_DATE'
EXPORTING
id_date = l_date
id-operator = '-'
is_duration = 8
IMPORTING
ed_date = l_date2.
ENDCASE.
Regards,
Dilek -
FM to get the previous sunday date based on current date(sy-datum)
hi all,
Is there any function module to get the previous sunday date based on current date(sy-datum)?
Regards,
Kapil Sharma
Moderator Message: Basic date related questions are not allowed
Edited by: Suhas Saha on Sep 19, 2011 11:39 AMHi,
There are function modules to find out the current day of the week depending on sy-datum. These are as below:
1. DATE_COMPUTE_DAY - Returns a number indicating what day of the week the date falls on. e.g. Monday is returned as a 1, Tuesday as 2,...., Sunday as 7.
2. RH_GET_DATE_DAYNAME - Returns the day based on the date provided, e.g. Monday, Tuesday,..., Sunday.
Using any of the above, if you can find out the current day, then you can calculate and compute the date of the previous Sunday.
My observation is that using the first FM might make the calculation simpler.
Hope this is of help to you.
Regards,
Shayeree -
Get working day of month for specific date
Hi,
I need to get the working day of a month for a specific date. For example: Which working day is the 15th of september 2005...
Is there any function module, I could use?
Cheers ArneHI arne,
1. DATE_CHECK_WORKINGDAY
This is the FM.
2. Along with that u will have to use some logic.
3. Just copy paste in new program
(it will help in the logic)
<b>It will list out
all the working days
between two given dates</b>
REPORT abc.
data : num type i.
parameters : frdate type sy-datum default '20051216'.
parameters : todate type sy-datum default '20051221'.
perform getinfo using frdate todate changing num.
break-point.
*& Form getinfo
text
FORM getinfo USING fromdate todate CHANGING numofdays type i.
DATA : d TYPE sy-datum.
d = fromdate - 1.
DO.
d = d + 1.
IF d > todate.
EXIT.
endif.
CALL FUNCTION 'DATE_CHECK_WORKINGDAY'
EXPORTING
date = d
factory_calendar_id = '01'
message_type = 'I'
EXCEPTIONS
date_after_range = 1
date_before_range = 2
date_invalid = 3
date_no_workingday = 4
factory_calendar_not_found = 5
message_type_invalid = 6
OTHERS = 7.
IF sy-subrc = 0.
numofdays = numofdays + 1.
write :/ d.
ENDIF.
ENDDO.
ENDFORM. "getinfo
regards,
amit m. -
How to get the Day of the Month and Date on Home Screen
The home screen has the signal strength on the upper left, the time in the middle and the battery status on the right. What is missing from my old phone (really, really old phone) is the day - like Sunday, and the date - like the 20th. I have to go to a calendar program to get what should be available at a glance, just like the time.
Can this be done?
aehaasIf you put the Apple calendar app on the first screen, it shows the day and date (no month/year). E.g Sunday 20.
-
Simple select to get data based on a date
Hi all
I have written some data to a table and am having issues trying to do a select and get that data based on the query.
I want to filter on a column called: TIMESTAMP based on the condition that the data was written to the DB on the following date:
01-OCT-09 10.47.35.597914000
I thought this would be enough:
select * from tableX
where current_value = 999
and TIMESTAMP = '01-Oct-2009'
I know the 999 exists because if I take out the last line I get the data I want.
A basic question I know but any help much appreciated.Dird wrote:
Hi Boneist,
When using > or < I use TO_DATE with DD-MON-YYYY or whatever format I need. TO_CHAR just comes to mind naturally when I need an equality test.
MikeHmm....
Let's see ->
satyaki>
satyaki>select * from v$version;
BANNER
Oracle Database 11g Enterprise Edition Release 11.1.0.6.0 - Production
PL/SQL Release 11.1.0.6.0 - Production
CORE 11.1.0.6.0 Production
TNS for 32-bit Windows: Version 11.1.0.6.0 - Production
NLSRTL Version 11.1.0.6.0 - Production
Elapsed: 00:00:00.02
satyaki>
satyaki>
satyaki>select * from emp;
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7369 SMITH CLERK 7902 17-DEC-80 800 20
7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30
7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30
7566 JONES MANAGER 7839 02-APR-81 2975 20
7654 MARTIN SALESMAN 7698 28-SEP-81 1250 1400 30
7698 BLAKE MANAGER 7839 01-MAY-81 2850 30
7782 CLARK MANAGER 7839 09-JUN-81 2450 10
7788 SCOTT ANALYST 7566 19-APR-87 3000 20
7839 KING PRESIDENT 17-NOV-81 5000 10
7844 TURNER SALESMAN 7698 08-SEP-81 1500 0 30
7876 ADAMS CLERK 7788 23-MAY-87 1100 20
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7900 JAMES CLERK 7698 03-DEC-81 950 30
7902 FORD ANALYST 7566 03-DEC-81 3000 20
7934 MILLER CLERK 7782 23-JAN-82 1300 10
14 rows selected.
Elapsed: 00:00:00.07
satyaki>
satyaki>
satyaki>select *
2 from emp
3 where hiredate < to_date('01-MAR-1981','DD-MON-YYYY');
EMPNO ENAME JOB MGR HIREDATE SAL COMM DEPTNO
7369 SMITH CLERK 7902 17-DEC-80 800 20
7499 ALLEN SALESMAN 7698 20-FEB-81 1600 300 30
7521 WARD SALESMAN 7698 22-FEB-81 1250 500 30
Elapsed: 00:00:00.00
satyaki>
satyaki>select *
2 from emp
3 where to_char(hiredate,'DD-MON-YYYY') < {noformat}'{noformat}01-MAR-1981{noformat}'{noformat} ;
no rows selected
Elapsed: 00:00:00.00
satyaki>
satyaki>So, as you can clearly see considering date as string may cost you heavy. Or don't you think so?
Regards.
Satyaki De.
N.B.: Some problem with the formatting. So, date is not appearing in the second case. :( -
Updation of SO Confirmed Delivery date based on GR date for BANC parts
Dear All,
Would appreciate an answer on the following issue:
For Back to back/Indiv Purchase Order parts(BANC) the confirmed delivery date in the SO is updated based on the Order Acknowledgement date sent by the vendor for the corresponding PO generated for the SO. If the the vendor happens to deliver the parts in advance of the OA date(it happens quite often), the parts wait in stores till the confirmed delivery date is reached on the SO even thugh the original requested date on the Sales order is long past. If there is an order acknowledgement date in the system, at the time of GR, a warning message comes, but as our system is a high volume systme it is not possible to update the date in SO manually. Is there a way we can update the confirmed delivery date in the SO based on the Goods receipt date automaticall through config or a batch job?
Thanks
SumanDspsac,
Delivery date can be any date. For instance, if your customer insisted on a Sunday delivery, you would accommodate him, regardless of any calendar.
From the delivery date, the system counts backwards USING THE FACTORY CALENDAR ASSIGNED TO THE ROUTE by the number of days in the route. You have to consult the FC assigned to your Route to determine if the GI date has been properly calculated.
From the GI date, the system counts backward Pick/pack time, using the shipping point calendar, to arrive at Material availability date.
Calculations are explained in SAP online help
[Transportation and Delivery Scheduling|http://help.sap.com/erp2005_ehp_04/helpdata/EN/dd/5607e7545a11d1a7020000e829fd11/frameset.htm]
Regards,
DB49 -
Date based Resultset and Date display
Hi
I have two jsp pages. In first page user selects a Date and name, based on that 2nd jsp display a resultset in a table. I want to Display Selected name and Date on 2nd Page. I done it for name and unable to show the Date and query is also to be modified.
Here is code for my two jsp pages:
first.jsp
<%@ taglib uri="http://java.sun.com/jstl/sql" prefix="sql" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ include file="DataSource.jsp" %>
<html>
<head>
<title>abcd</title>
<script type="text/javascript" language="javascript">
function HTML(p){
if(!p){
/*default*/
p='A action align alt B background Base bgcolor BIG BLINK BODY border bordercolor bordercolordark bordercolorlight Br cellpadding cellspacing checked color cols colspan compact content dir DIV enctype face FONT FORM H1 H2 H3 H4 H5 H6 HEAD height Hr href hspace HTML I id Img Input lang language leftmargin LI marginheight marginwidth maxlength Meta method name NOSCRIPT noshade nowrap OL onblur onchange onclick onfocus onload onmouseout onmouseover onreset onselect onsubmit onunload OPTION P PRE profile readonly rows rowspan SCRIPT SELECT size SMALL SPAN src start STRIKE STYLE style SUB SUP TABLE target TD TEXTAREA TH TITLE title topmargin TR TT type U UL valign value vspace width wrap'
String.prototype.write=function(){
document.write(this);
return this
String.prototype.alert=function(){
window.alert(this);
return this
String.prototype.status=function(){
window.status=this;
return this
var x=[
function(W){var q=String.fromCharCode(34);return ' x='+q+((typeof(W)!='undefined')?W:'x')+q}/*attr*/,
function(W){return '<x'+((typeof(W)!='undefined')?W:'')+' />'}/*tag*/,
function(W){return '<x'+((typeof(W)!='undefined')?W:'')+'>'+this+'</'+'x>'}/*container*/,
function(W){var o='<x'+((typeof(W)!='undefined')?W:'')+' />';return o+this.join(o)}/*tags*/,
function(W){var o='<x'+((typeof(W)!='undefined')?W:'')+'>';var c='</'+'x>';return o+this.join(c+o)+c}/*containers*/
var j=[];
var f=0;
var a=p.split(' ');
var t,u,l;
for(var i=0;i<a.length;i++){
t=a;
u=t.toUpperCase();
l=t.toLowerCase();
if(t==l){
/*attr*/
j[f]='window.'+u+'='+x[0]
else if(t==u){
/*container;containers*/
j[f]='String.prototype.'+u+'='+x[2]+';Array.prototype.'+u+'='+x[4]
else{
/*tag;tags*/
j[f]='window.'+u+'='+x[1]+';Array.prototype.'+u+'='+x[3]
/*specific*/
j[f]=j[f].replace(/x/g,l);
f++
window.status='HTML() bookmarklet library: Copyright (c) 2002-'+(new Date()).getFullYear()+', by Richard Edwards. ['+f+' tag/attrs added] ';
/*implement!*/
eval(j.join(';'))
HTML();
</script>
<script type="text/javascript" language="javascript">
function init(){m='January February March April May June July August September October November December'.split(' ');wd='Su M Tu W Th Fr Sa'.split(' ');lom=[31,28,31,30,31,30,31,31,30,31,30,31];sz=25;js='javascript';fn=[function(F){},function(F){DATE=new Date(F.date.value);if(isNaN(DATE.valueOf())){DATE=new Date()};M=DATE.getMonth();D=DATE.getDate();Y=DATE.getFullYear();lom[1]=28;if((Y%/**/4==0)&&((Y%/**/100>0)||(Y%/**/400==0))){lom[1]++}},function(F){if(D>lom[M]){D=lom[M]};F.date.value=(M<9?'0':'')+(1.0+M)+'/'+(D<10?'0':'')+D+'/'+Y;dv.value=F.date.value;if(opener.Page){opener.document.forms[0][dv.name].value=F.date.value}},function(){F=this.form;fn[1](F);M=this.selectedIndex;fn[2](F);fn[0](F)},function(){F=this.form;fn[1](F);D=this.value;fn[2](F);fn[0](F)},function(){F=this.form;fn[1](F);Y=this.value;fn[2](F);fn[0](F)},function(F){fn[1](F);var f=new Date(Y,M,1);var x=1-(f.getDay());for(var i=0;i<49;i++){F.d[i].value=(i<7?wd[i]:'');F.d[i].onclick=this;};for(var i=1;i<=lom[M];i++){w=Math.floor((i-1)/7);n=7+i-x;F.d[n].value=i;F.d[n].onclick=fn[4];if(i==D){F.d[7+i-x].focus()}};for(var i=0;i<F.m.length;i++){F.m[i].selected=(i==M)};F.m.onchange=fn[3];F.y.value=Y;F.y.onchange=fn[5];F.y.onblur=fn[5];fn[2](F)}];fn[0]=fn[6]};init();function popCal(datevalue){if(!datevalue){dv={name:'Today',value:(new Date())}}else{dv=datevalue};var c=ALIGN('center')+HEIGHT(sz);var h=(m.OPTION().SELECT(NAME('m'))+INPUT(TYPE('text')+SIZE(4)+NAME('y'))+INPUT(TYPE('hidden')+NAME('date')+VALUE(dv.value))).TD(COLSPAN(7)+c);var b=INPUT(TYPE('button')+NAME('d')+STYLE('width:'+sz+';height:'+sz)+WIDTH(sz)+c);var r=[b,b,b,b,b,b,b].TD(WIDTH(sz*7)+c);h=[h,r,r,r,r,r,r,r].TR(c).TABLE(BORDER('0')+CELLSPACING('0')+CELLPADDING('0')+c).FORM(NAME('frm')+ACTION(js+'://'));h+=(init+';init();dv=opener.dv;fn[0](document.forms.frm);').SCRIPT(LANGUAGE(js)+TYPE('text/'+js));window.open('','cal'+(new Date()).valueOf(),'height='+sz*9+',width='+sz*8).document.write(h)};
</script>
</head>
<body bgcolor=lightblue>
<center><h1>xyz</h1></center>
<hr>
<br>
<p>
<p>
<p>
<p>
<h4>Select a date: </h4>
<script type="text/javascript" language="javascript">
(INPUT(NAME("DV")+READONLY())+INPUT(TYPE("button")+VALUE("Calendar..")+ONkLICK("popCal(this.form.DV)"))).FORM().write();
</script>
<p>
<p>
<br>
<form method=post action="second.jsp">
<sql:transaction dataSource="${example}">
<sql:query var="Power">
select unique trader_name from exchange_deal where unit_of_measure='mwh'
</sql:query>
</sql:transaction>
<h4><p>Select a Trader:
<select Name = "TraderDrop">
<c:forEach var="row" items="${Power.rows}">
<option size="20"><c:out value="${row.Trader_name}"/></option>
</c:forEach>
</select>
<p>
</h4>
<br>
<input type="submit" value="SUBMIT"/>
<input type="reset" value="CANCEL"/>
</form>
</body>
</html>
Second jsp
<%@ taglib uri="http://java.sun.com/jstl/sql" prefix="sql" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<%@ include file="DataSource.jsp" %>
<html>
<head>
<title>abc</title>
</head>
<body bgcolor=lightblue>
<center><h1>xyz</h1></center>
<hr>
<form name="input" action="pqr.jsp"
method="get">
<c:set var="s" value="${param.TraderDrop}" />
<h3>Trader : <c:out value="${s}" /></h3>
<c:set var="d" value="${param.date}" />
<h3>Trade Date: <c:out value="${d}" /></h3>
<sql:transaction dataSource="${example}">
<sql:query var="Power">
SELECT DEAL_ID, DEAL_TYPE, EXCHANGE_NAME, HUB_NAME, ORGINATING_APPLICATION, PRODUCT_ID, TAKER_COMPANY FROM ENYWARE.EXCHANGE_DEAL where TRANSACTION_TIMESTAMP > sysdate - 3 and trader_name = '<c:out value="${s}" />'
</sql:query>
</sql:transaction>
<table border="1">
<%-- Get the column names for the header of the table --%>
<tr>
<c:forEach var="columnName" items="${Power.columnNames}">
<th><c:out value="${columnName}"/></th>
</c:forEach>
</tr>
<tr>
<c:forEach var="column" items="${row}">
<td><c:out value="${column.value}"/></td>
</c:forEach>
</tr>
</c:forEach>
</table>
</form>
</body>
</html>
I am using JavaScript calendar for entering date in a Text box.
Please review code and help me.
Thanks in Advance
SuryaAnitha123 wrote:
Hi
Thanks for your reply..
We execute our application using a batch file which holds the main class file to be executed as below :
batch file content as below :
set PATH=.\_jvm\bin
set JAVA_HOME=.\_jvm
set CLASSPATH=.\_jvm\lib\rt.jar;.\_jvm\lib\itext.jar
java -cp %CLASSPATH%;.\classes xx.yy.zz.Ourmainclass
Here how can i set the time zone as users time zone? we don't use any manifest file for our application..can you please guide me on the same..Very Good...Then here is your answer..
set PATH=.\_jvm\bin
set JAVA_HOME=.\_jvm
set CLASSPATH=.\_jvm\lib\rt.jar;.\_jvm\lib\itext.jar
java -Duser.timezone=Asia/Calcutta -cp %CLASSPATH%;.\classes xx.yy.zz.OurmainclassIf this will solve your problem.. don't forget to reward duke stars...please.. -
Invoice Date Based on POD Date and Requested Delivery Date
Hello Experts,
Could you please Help me How to get the Billing date in the invoice document based on POD date if the POD Report has been Posted , If not the system should pick up the requested delivery date.
Thanks for your timeHi,
Create an copy control routine (T.Code VOFM) as assign in copy control setting between Delivery doc to billing docuement (T.code VTFL).
The new routine will be created with copy of existing routine assign under "Copying requirements" at item level, and assign on same place.
Pl take help of ABAPer to write the new routine.
regards
Vivek.
Edited by: Vievk Vardhan on Jan 7, 2010 1:50 PM -
Last month end date based on current date
Hi,
How to show last month end date based on the current date.
Eg:
Current date = "08/26/09"
Var- Last Month End Date = "07/31/09" etc...,
Please help me how to get it...
Thank You!Good to hear that it worked for you. but not for me.
I tried like this:
1st::
1. var1= ToDate("06/30/09","MM/dd/yyyy")
2.Var2= RelativeDate([Var1];-DayNumberOfMonth([Var1]))
result: 5/30/09
2nd:
RelativeDate('6/30/2009';-DayNumberOfMonth('6/30/2009'))
result: 5/30/09
Am working on SAP OLAP cubes.
Please help me where am going wrong....
Thank You! -
How to schedule report filtered by dynamic date based on the date the Agent runs
Hello
I have a question about delivering report using OBIEE agent.
If i am running an agent today to deliver report A, can I get report A based on Last Monday's date or any dynamic dates?
For example, say today is Dec 18th 2013 and my agent is running according to how I set the schedule. Now the deliver content will have report A being delivered. Now report A has a date column, normally this column is filtered by current date. But if it's delivered through agents to various users, Report A's data should be the previous Monday, so in this case Dec 9th 2013. When this agent is run again said on Dec 27th 2013, then report A should be filtered by Dec 16th 2013, which is the previous monday of Dec 27th.
Can something like this be achieved in OBIEE 11G?
Thanks in advance.Yala,
Not a straight forward way
1) Let the report run through Agent with Current Date filter
2) once it ran for the first time you can see IBOT name/last run time(LAST_RUNTIME_TS) in S_NQ_JOB
Create a repository variable 'last_run_agent' using below sql to get max(LAST_RUNTIME_TS)
select max(LAST_RUNTIME_TS) from s_nq_job where name = 'AGENT_NAME';
Edit the analysis report with current date filter and modify the filter condition accordingly to filter on newly created repository variable
Thanks,
Saichand -
Calendar with preselected dates based on current date
Can we get the calendar to be prepopulated with todays' date and today-7 date as the default before it starts running the initial queries when I log into dashboard.
I have a calendar date range based on which my chart displays metrics. If I dont choose anything its picking up all the data first before I choose something
Your help is always appreciated.I apologize I read your post too quickly and misunderstood your question. Unfortunately, I thought you were referring to a dashboard you had created and asking about setting up default dates for your bind variables/parameters.
Well I'll have to leave this one to someone else. Sorry I couldn't be more help.
David -
How to get the day of 52 weeks ago data
hi all:
i recently encounter the difficulty that using the current data to get the 52 weeks ago data in essbase.the fct table is like this:
current_dt the_day_of_week sales
20110203 5dw05 100
20100207 5dw05 30
note: "5dw05" means the fifth day of five week in the selected year
the question is which essbase formula to choise or how to use them in essbase outline structure can meet the bussines role that when the biz men chlic on the member "20110203" of time dimension, the extension mesure "bf_sales" value is 30.
the outline i am about to design under the bellow:
dim_time
201002
20110201(alias 4dw05)
20110202(alias 5dw05)
20110203(alias 6dw05)
201102
20110206(alias 4dw05)
20110207(alias 5dw05)
dim_measure
sales
bf_sales(will use the essbase formula,but do not know which function to choise or how to use it)
i am lovely hope one of you may give me suggestion on this issue. thanks a lot for all of you!If you put the Apple calendar app on the first screen, it shows the day and date (no month/year). E.g Sunday 20.
-
How to get the data based on below data-----pls help me...
Hi,
i have the data in my table.......
SET_ID SET_Name Status date user_name
SET974 F698671 I 24/03/2011 10:40:05 TEST1
SET974 F698671 I 24/03/2011 10:40:05 TEST1
SET974 F698671 N 24/03/2011 10:40:05 TEST1
SET974 F698671 I 24/03/2011 10:40:05 TEST1
SET528 A258961 I 22/03/2011 9:40:05 TEST2
SET528 A258961 N 22/03/2011 9:40:05 TEST2
SET528 A258961 I 22/03/2011 9:40:05 TEST2
SET528 A258961 I 22/03/2011 9:40:05 TEST2
SET974 F698671 I 25/03/2011 13:40:05 TEST1
SET974 F698671 N 25/03/2011 13:40:05 TEST1
SET974 F698671 N 25/03/2011 13:40:05 TEST1
SET974 F698671 I 25/03/2011 13:40:05 TEST1
SET974 F698671 I 26/03/2011 15:40:05 TEST5
SET974 F698671 N 26/03/2011 15:40:05 TEST5
SET974 F698671 N 26/03/2011 15:40:05 TEST5
SET974 F698671 I 26/03/2011 15:40:05 TEST5
I want to know each user ,how many sets modified.
based on above input data,my output would be in the following way:
user_name no.of sets upated for single user
TEST1 2
TEST2 1
TEST5 1Based on your sample data, why does TEST1 have a count of 2? From what I can see, the only SET_ID that is associated with TEST1 is SET974 so I would think that you'd want TEST1 to have a count of 1.
If I ignore the data you posted and just look at the text of your requirements, I would guess that you wanted
SELECT user_name, COUNT( DISTINCT set_id ) cnt
FROM some_table
GROUP BY user_nameThis won't give the output you said you wanted based on the sample data you provided, however, for the reason I outlined above.
If you actually do expect to get the output you posted from the sample data you posted, can you explain in a bit more detail why TEST1 should have a value of 2? It would also be helpful to post the CREATE TABLE and INSERT statements rather than just dumping the data. If you provide DDL & DML, we can create the objects locally and verify our solutions rather than guessing based on eyeballing the data.
Justin
Maybe you are looking for
-
Partial reversal of a goods receipt from process order
Dear All Could anyone please help me with explaining how to do a partial reversal of a goods receipt from process order? If Iu2019m using trans CORS I have to cancel the entire operation, which I donu2019t want to do. If Iu2019m using MIGO and MT 102
-
Unable to install itunes 64 bit
Every time I install iTunes on my 64 bit version of windows, it installs it as the 32 bit version. I have tried uninstalling and reinstalling with the iTunes64setup and it still installs the the application as the 32 bit version, saving it in Program
-
Broken wb and magenta tint shift on all my 30D images
Hi everybody...I know that there is another post regarding images going green...I read it all and tried to follow some of the listed suggestions but no success at all...I'm really in the middle of nowhere, don't know what to do to escape from this ni
-
Instrument I/O Assistant problems
Hi, I am having trouble using the I/O assistant through my parallel port. It is not writing to it. The VI example, Parallel Port Read and Write Loop, works just fine. Is there a way to use the I/O Assistant instead? Thanks, Ryan
-
Hi guys . I want to know how to beable to alter (crop) a picture from my pc and use it as a wallpaper on my fone (Nokia 6682) I have done it a long time ago, but I forget how to now... cheers