Help with SQL Script please
Hi there,
What I`m trying to accomplish here is the following guys;
This would be the pseudo code that I`m trying to convert into proper SQL;
Declare @Parameter varchar(50)
now I`m trying to find out how to find whatever is in the @Parameter in the values of table column. something like this;
If @Parameter exists in (select column from table) then do something here else something else....
Thanks very much in advance for your help.
do you want some thing like below
Declare @Parameter varchar(50)
If exists (select column from table where column = @Parameter)
begin
--do something here
END
else
Begin
--something
END
Thanks
Saravana Kumar C
Similar Messages
-
I need help with this script please ASAP
So I need this to work properly, but when ran and the correct answer is chosen the app quits but when the wrong answer is chosen the app goes on to the next question. I need help with this ASAP, it is due tommorow. Thank you so much for the help if you can.
The script (Sorry if it's a bit long):
#------------Startup-------------
display dialog "Social Studies Exchange Trviva Game by Justin Parzik" buttons {"Take the Quiz", "Cyaaaa"} default button 1
set Lolz to (button returned of the result)
if Lolz is "Cyaaaa" then
killapp()
else if Lolz is "Take the Quiz" then
do shell script "say -v samantha Ok starting in 3…2…1…GO!"
#------------Question 1-----------
display dialog "Around age 11, many boys left their fathers to become…" buttons {"Scholars", "Warriors", "Apprentices"}
set A1 to (button returned of the result)
if A1 is "Apprentices" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
#----------Question 2--------
display dialog "Most children were taught
to read so that they could understand the…" buttons {"Music of Mozart", "Bible", "art of cooking"}
set A2 to (button returned of the result)
if A2 is "Bible" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
#------------Question 3---------
display dialog "In the 1730s and 1740s, a religious movement called the_______swept through the colonies." buttons {"Glorius Revolution", "Great Awakening", "The Enlightenment"}
set A3 to (button returned of the result)
if A3 is "Great Awakening" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
#-----------Question 4--------
display dialog "_______ was
a famous American Enlightenment figure." buttons {"Ben Franklin", "George Washington", "Jesus"}
set A4 to (button returned of the result)
if A4 is "Ben Franklin" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
#----------Question 5-------
display dialog "______ ownership gave colonists political rights as well as prosperity." buttons {"Land", "Dog", "Slave"}
set A5 to (button returned of the result)
if A5 is "Land" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
#---------Question 6--------
display dialog "The first step toward guaranteeing these rights came in 1215. That
year, a group of English noblemen forced King John to accept the…" buttons {"Declaration of Independence", "Magna Carta", "Constitution"}
set A6 to (button returned of the result)
if A6 is "Magna Carta" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
#----------Question 7--------
display dialog "England's cheif lawmaking body was" buttons {"the Senate", "Parliament", "King George"}
set A7 to (button returned of the result)
if A7 is "Parliament" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
#--------Question 8-----
display dialog "Pariliament decided to overthrow _______ for not respecting their rights" buttons {"King James II", "King George", "King Elizabeth"}
set A8 to (button returned of the result)
if A8 is "King James II" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
#--------Question 9------
display dialog "Parliament named ___ and ___ as England's new monarchs in something called ____." buttons {"William/Mary/Glorius Revolution", "Adam/Eve/Great Awakening", "Johhny/Mr.Laphalm/Burning of the hand ceremony"}
set A9 to (button returned of the result)
if A9 is "William/Mary/Glorius Revolution" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
#---------Question 10-----
display dialog "After accepting the throne William and Mary agreed in 1689 to uphold the English Bill of _____." buttons {"Money", "Colonies", "Rights"}
set A10 to (button returned of the result)
if A10 is "Rights" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
#---------Question 11------
display dialog "By the late 1600s French explorers had claimed the ___ River Valey" buttons {"Mississippi", "Ohio", "Hudson"}
set A11 to (button returned of the result)
if A11 is "Ohio" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
#------Question 12---------
display dialog "______ was sent to ask the French to leave 'English Land'." buttons {"Johhny Tremain", "George Washington", "Paul Revere"}
set A12 to (button returned of the result)
if A12 is "George Washington" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
#---------Question 13-------
display dialog "_____ proposed the Albany Plan of Union" buttons {"George Washingon", "Ben Franklin", "John Hancock"}
set A13 to (button returned of the result)
if A13 is "Ben Franklin" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
#--------Question 14------
display dialog "The __________ declared that England owned all of North America east of the Mississippi" buttons {"Proclomation of England", "Treaty of Paris", "Pontiac Treaty"}
set A14 to (button returned of the result)
if A14 is "" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
#-------Question 15-------
display dialog "Braddock was sent to New England so he could ______" buttons {"Command an attack against French", "Scalp the French", "Kill the colonists"}
set A15 to (button returned of the result)
if A15 is "Command an attack against French" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
#------TheLolQuestion-----
display dialog "____ is the name of the teacher who runs this class." buttons {"Mr.White", "Mr.John", "Paul Revere"} default button 1
set LOOL to (button returned of the result)
if LOOL is "Mr.White" then
do shell script "say -v samantha Congratulations…you…have…common…sense"
else
do shell script "say -v alex Do…you…have…eyes?"
#------END------
display dialog "I hope you enjoyed the quiz!" buttons {"I did!", "It was horrible"}
set endmenu to (button returned of the result)
if endmenu is "I did!" then
do shell script "say -v samantha Your awesome"
else
do shell script "say -v alex Go outside and run a lap"
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end if
end ifUse code such as:
display dialog "Around age 11, many boys left their fathers to become…" buttons {"Scholars", "Warriors", "Apprentices"}
set A1 to (button returned of the result)
if A1 is "Apprentices" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
return
end if
#----------Question 2--------
display dialog "Most children were taught to read so that they could understand the…" buttons {"Music of Mozart", "Bible", "art of cooking"}
set A2 to (button returned of the result)
if A2 is "Bible" then
do shell script "say -v samantha Correct Answer"
else
do shell script "say -v samantha Wrong Answer"
return
end if
(90444) -
Help with action script please
hay guys, im having trouble with changing my action script to
allow multiple layers of the same thing in order to show a greater
sense of depth than the normal application. im using a flash
toutorial on making a sort of matrix like falling text (
link)
and im not completely understanding what to change in order to
accomplish my goal. i tryed to send them a message using their
contact page, but its broken, forcing me to find a forum. im sure
it has something to do with the third group of code where it
identifies what its using. but whenever i change anything there to
either match the identifiers or movie clip names the action script
crashes when i test the movie. any help is appreciated.
im using flash cs3 and made sure to create it all in action
script 2.0
please excuse my spelling, im sure i made a mistake
somewhere."FlashTastic" <[email protected]> wrote in
message news:e4ir4t$ru4$[email protected]..
>I don't think an enterframe will be your best bet.
>
> You might want to use something like
>
> if(_root._currentframe >= _root.totalframes){
> loadMovie("myMovie.swf",_root)
Why in the world would you do that when you can just put a
keyframe on the last frame and ..
loadMovie("myMovie.swf");
tralfaz -
This is a script that I am using to batch flatten and rotate(if needed) files. This script is working intermittently and I can't seem to get a handle on why I keep getting the error message:
- Could not save as "" because the file could not be found.
Line: 66
executeAction( idsave, desc64, DialogModes.NO );
Please if anyone could help me that would be great. It is getting rather annoying that it works sometimes and other times it does not. Thanks in advance.
Clevadio
//=============Find Current Documents path================//
var CurrentPath = activeDocument.path;
//=============Establish current documents destination===============//
var folder1 = Folder(CurrentPath + '/' + 'Flats');
//=============Check if it exist, if not create it.============//
if(!folder1.exists) folder1.create('Flats');
//=============Establish current documents file name=========//
var CurrentFileName = activeDocument.name;
//=============Modify current file name================//
var modifiedFileName = CurrentFileName.replace( ".psd", "Flat" );
//=============Establish save path====================//
var saveFileCurrentPath = new File(folder1 + '/' + modifiedFileName);
//=============Flatten document ====================//
var idFltI = charIDToTypeID( "FltI" );
executeAction( idFltI, undefined, DialogModes.NO );
//=============Rotate document if in 'Landscape'====================//
if (app.documents.length > 0) {
var myDocument = app.activeDocument;
if (myDocument.width > myDocument.height) RotateToPortrait();
function RotateToPortrait(){
try{
var idRtte = charIDToTypeID( "Rtte" );
var desc2 = new ActionDescriptor();
var idnull = charIDToTypeID( "null" );
var ref1 = new ActionReference();
var idDcmn = charIDToTypeID( "Dcmn" );
var idOrdn = charIDToTypeID( "Ordn" );
var idFrst = charIDToTypeID( "Frst" );
ref1.putEnumerated( idDcmn, idOrdn, idFrst );
desc2.putReference( idnull, ref1 );
var idAngl = charIDToTypeID( "Angl" );
var idAng = charIDToTypeID( "#Ang" );
desc2.putUnitDouble( idAngl, idAng, 90.000000 );
executeAction( idRtte, desc2, DialogModes.NO );
return activeDocument.activeLayer;
}catch(e){}
// =======================================================
//=============Now save document ====================//
var idsave = charIDToTypeID( "save" );
var desc64 = new ActionDescriptor();
var idAs = charIDToTypeID( "As " );
var desc67 = new ActionDescriptor();
var idmaximizeCompatibility = stringIDToTypeID( "maximizeCompatibility" );
desc67.putBoolean( idmaximizeCompatibility, false );
var idPhtthree = charIDToTypeID( "Pht3" );
desc64.putObject( idAs, idPhtthree, desc67 );
var idIn = charIDToTypeID( "In " );
desc64.putPath( idIn, new File( saveFileCurrentPath ) );
executeAction( idsave, desc64, DialogModes.NO );
activeDocument.close()You can turn off some of the dialogs with: app.displayDialogs = DialogModes.NO;
#target photoshop
if (app.documents.length > 0) {
//Turn display dialogs off
app.displayDialogs = DialogModes.NO;
//=============Find Current Documents path================//
var CurrentPath = activeDocument.path;
//=============Establish current documents destination===============//
var folder1 = Folder(CurrentPath + '/' + 'Flats');
//=============Check if it exist, if not create it.============//
if(!folder1.exists) folder1.create();
//=============Establish current documents file name=========//
//Current filename without the extension
var CurrentFileName = app.activeDocument.name.replace(/\.[^\.]+$/, '');
//=============Modify current file name================//
var modifiedFileName = CurrentFileName +"Flat.psd";
//=============Establish save path====================//
var saveFileCurrentPath = new File(folder1 + '/' + modifiedFileName);
//=============Flatten document ====================//
activeDocument.flatten();
//=============Rotate document if in 'Landscape'====================//
var myDocument = app.activeDocument;
if (myDocument.width > myDocument.height) myDocument.rotateCanvas(90);
//============Save File=======================//
psdSaveOptions = new PhotoshopSaveOptions();
activeDocument.saveAs(saveFileCurrentPath, psdSaveOptions, true, Extension.LOWERCASE);
//Close Document
app.activeDocument.close(SaveOptions.DONOTSAVECHANGES); -
I have 2 Tables
TABLE_NAME COLUMN_NAME DATA_TYPE
TASTEWINE TWDATE DATE
TASTEWINE BIN NUMBER
TASTEWINE QUANTITY NUMBER
TASTING TDATE DATE
TASTING PLACE VARCHAR2
a) Table TASTING has 2 columns.... TDATE( date Tasting was Held) and PLACE ( locations at which Tasting was held)
b) Table TASTEWINE has 3 Columns.............. TWDATE( wine tasting date, BIN( ID number for type of wine that was tasted), AND QUANTITY( quantity of win consumed by bottles)
Here is the QUestion.... I am having a hard time figuring out how to connect those two tables based on this information .. What I want to do is this.....select the total number of bottles of wine served at each wine-tasting, but only for the second half of the year 1999, and I want to see not only the date and total bottles served, but also the location where the wine-tasting took place. I also want to display the date, the place, and total quantity.
Can Anyone please Help me??Hi,
Your query works fine - as well as the one mentioned by Alok. I have tired it with some sample values, and both show the same results:-
The two tables :-
CREATE TABLE TASTEWINE
TWDATE DATE,
BIN NUMBER,
QUANTITY NUMBER
CREATE TABLE TASTING
TDATE DATE,
PLACE VARCHAR2(100)
);Rows in the Tables:-
INSERT INTO TASTEWINE VALUES (TO_DATE('01/12/1999','MM/DD/YYYY'),1,100);
INSERT INTO TASTEWINE VALUES (TO_DATE('02/12/1999','MM/DD/YYYY'),1,100);
INSERT INTO TASTEWINE VALUES (TO_DATE('03/12/1999','MM/DD/YYYY'),1,100);
INSERT INTO TASTEWINE VALUES (TO_DATE('04/12/1999','MM/DD/YYYY'),1,100);
INSERT INTO TASTEWINE VALUES (TO_DATE('05/12/1999','MM/DD/YYYY'),1,100);
INSERT INTO TASTEWINE VALUES (TO_DATE('06/12/1999','MM/DD/YYYY'),1,100);
INSERT INTO TASTEWINE VALUES (TO_DATE('07/12/1999','MM/DD/YYYY'),1,100);
INSERT INTO TASTEWINE VALUES (TO_DATE('08/12/1999','MM/DD/YYYY'),1,100);
INSERT INTO TASTEWINE VALUES (TO_DATE('09/12/1999','MM/DD/YYYY'),1,100);
INSERT INTO TASTEWINE VALUES (TO_DATE('10/12/1999','MM/DD/YYYY'),1,100);
INSERT INTO TASTEWINE VALUES (TO_DATE('11/12/1999','MM/DD/YYYY'),1,100);
INSERT INTO TASTEWINE VALUES (TO_DATE('12/12/1999','MM/DD/YYYY'),1,100);
INSERT INTO TASTEWINE VALUES (TO_DATE('01/12/2000','MM/DD/YYYY'),1,100);
INSERT INTO TASTEWINE VALUES (TO_DATE('02/12/2000','MM/DD/YYYY'),1,100);
INSERT INTO TASTEWINE VALUES (TO_DATE('03/12/2000','MM/DD/YYYY'),1,100);
INSERT INTO TASTEWINE VALUES (TO_DATE('04/12/2000','MM/DD/YYYY'),1,100);
COMMIT;
INSERT INTO TASTING VALUES (TO_DATE('01/12/1999','MM/DD/YYYY'),'SEATTLE');
INSERT INTO TASTING VALUES (TO_DATE('02/12/1999','MM/DD/YYYY'),'SAN FRANSICO');
INSERT INTO TASTING VALUES (TO_DATE('03/12/1999','MM/DD/YYYY'),'DENVER');
INSERT INTO TASTING VALUES (TO_DATE('04/12/1999','MM/DD/YYYY'),'AUSTIN');
INSERT INTO TASTING VALUES (TO_DATE('05/12/1999','MM/DD/YYYY'),'SALT LAKE CITY');
INSERT INTO TASTING VALUES (TO_DATE('06/12/1999','MM/DD/YYYY'),'LOS ANGLES');
INSERT INTO TASTING VALUES (TO_DATE('07/12/1999','MM/DD/YYYY'),'PORTLAND');
INSERT INTO TASTING VALUES (TO_DATE('08/12/1999','MM/DD/YYYY'),'NEW YORK');
INSERT INTO TASTING VALUES (TO_DATE('09/12/1999','MM/DD/YYYY'),'NEWARK');
INSERT INTO TASTING VALUES (TO_DATE('10/12/1999','MM/DD/YYYY'),'EL PASO');
INSERT INTO TASTING VALUES (TO_DATE('11/12/1999','MM/DD/YYYY'),'AUSTIN');
INSERT INTO TASTING VALUES (TO_DATE('12/12/1999','MM/DD/YYYY'),'CHICAGO');
INSERT INTO TASTING VALUES (TO_DATE('01/12/2000','MM/DD/YYYY'),'ATLANTA');
INSERT INTO TASTING VALUES (TO_DATE('02/12/2000','MM/DD/YYYY'),'HOLLYWOOD');
INSERT INTO TASTING VALUES (TO_DATE('03/12/2000','MM/DD/YYYY'),'');
INSERT INTO TASTING VALUES (TO_DATE('04/12/2000','MM/DD/YYYY'),'SEATTLE');
COMMIT;The First Query :-
SELECT
A.TWDATE,
B.PLACE,
SUM(A.QUANTITY)
FROM
TASTEWINE A,
TASTING B
WHERE
A.TWDATE = B.TDATE
AND B.TDATE > TO_DATE('01/07/1999', 'DD/MM/YYYY')
AND B.TDATE < TO_DATE('01/01/2000', 'DD/MM/YYYY')
GROUP BY
A.TWDATE,
B.PLACE;The Second Query :-
SELECT
A.TWDATE,
B.PLACE,
SUM(A.QUANTITY)
FROM
TASTEWINE A,
TASTING B
WHERE
A.TWDATE = B.TDATE
AND B.TDATE
BETWEEN
TO_DATE('01/07/1999', 'DD/MM/YYYY') AND
TO_DATE('01/01/2000', 'DD/MM/YYYY')
GROUP BY
A.TWDATE,
B.PLACE;Regards,
Sandeep -
Help with Report Script please :(
Hi,
I'm trying to write a report script with a slight calculation and would really appreciate some help.
Ideally I want to create a report where I only get the Account and Value. I select all my members but I need a calculation on the Entity dimension. Here's what i am trying to achieve:
(All selected members for all Entities + All selected members for all Entities in group RIA-IFRS REPORTING ADJS. ) Yes I'm duplicating the members of group RI-IFRS REPORTING ADJS.
So account 100 for all Entities = 50
account 100 for all Entities in RI-IFRS REPORTING ADJS. = 25
I want to display account 100 grouped as 75 without showing a line for each entity.
This is what I have so far but it doesn't work right:
ROWREPEAT
SUPCOLHEADING
SUPCOMMAS
SUPHEADING
SUPBRACKETS
SUPEMPTYROWS
TABDELIMIT
MISSINGTEXT "#mi"
DECIMAL 2
NOINDENTGEN
<PAGE ( Years, Version, Currency, Scenario, InterCompany, "Entity", "Cost Center","Set of Books","Reporting")
"FY10" "Current" "Currency" "Actual" "InterCompany" "Entity" "Cost Center" "AB_CON_USD" "Reporting"
<ROW ("Account")
<LINK(<DESCENDANTS("Total Balance Sheet Accounts","Lev0,Account"))
{ CALCULATE ROW "Entity" = "Entity" + "RI-IFRS REPORTING ADJS."})
<COL (Period)
"Dec"
!Dreamscapeuk wrote:
Hi Robert, I wasn't getting any data, but I managed to figure that out. Basically I created 2 columns with the values I needed and then added them up with a calc cloumn. However I can't get my essbase substitution variables working. So I created a substitution variable called CurrQtr and set this to Quarter3. In my script I'm using this @CurrQtr as a period however it doesn't use it as it's just giving me the total for the Period dimension. Any help?
Here's the script:
ROWREPEAT
SUPCOMMAS
SUPBRACKETS
SUPEMPTYROWS
TABDELIMIT
MISSINGTEXT ""
DECIMAL 2
NOINDENTGEN
<PAGE ( DataSrc, Years, Version, "P&L Type", Currency, Scenario, InterCompany, "Cost Center","Set of Books","Reporting")
"DataSrc" "FY10" "Current" "No_Type" "USD" "Actual" "InterCompany" "Cost Center" "AB_CON_USD" "No_Cost_Type"
<COLUMN (Period)
@CurrQtr
WWL "RIA-IFRS REPORTING ADJS."
CALCULATE COLUMN "Gaap" = 1 - 2
ORDER 0,3,1,2
<ROW (Account)
<LINK(<DESCENDANTS("Global Accounts","Lev0,Account"))
In my script I'm using this @CurrQtr as a period however it doesn't use it as it's just giving me the total for the Period dimension. Any help?
I don't understand this...
*<COLUMN (Period)*
* Qtr3 WWL "RIA-IFRS REPORTING ADJS."*
have you tried like this.??
Edited by: Prabhas on Feb 1, 2011 12:05 AM -
query #1
can anyone helpme set up two scripts.
1 i need to list all users that belong to a single role or for all roles,which would be grouped by role,the number of users in the role,when the role was granted,what options went with the grant and who granted it to them.
i need a sample or the the views that need to be involved to extract that information.
query #2
another script that i need is the following:
i need to list object privileges by user or all users,
appropriately grouped,given to the user,the name and type of the object,when the grant was given and with what options they were granted,and who granted them the privilege.
so if any body could help in these two scripts i 'll be very appreciative.
thanks in advance.You want to run reports at least for intervals of an hour. A whole day's report wouldn't contain anything that would stand out because everything levels out when looking at everything that occurred over a long period of time. AWR snapshots are automatically scheduled to be taken every hour because that's the ideal range to look at reports for.
-
Hi All ,
Here is my usecase. I have a table of following structure (History table):
Column A - Unique key
Column B - Foreign Key
Start Date
End Date.
My Data is corrupted due to some reason . Its supposed to be
StartDate End Date
1 MyID 2010-04-01 2013-10-07
2 MyID 2013-10-07 3000-12-31
It got corrupted and now it is
StartDate End Date
1 MyID 2010-04-01 2013-10-07
2 MyID 2010-04-01 3000-12-31
Basically I want end date of first row to be updated as start date of second row. Because of some coding issue this corruption happened.
Now i want to find out all the cases for which this happened.
I could find out all the rows for which multiple entries are there using :
Select * from table where B in (
Select B from table group by b having count(*) >1)
But i need only corrupted records. Can some one help me ??
Thanks in advance.
B1Since you have not provided proper data, hope below table format matches your record set.
WITH T1 AS
( SELECT 1 COL1, 1 COL2, TO_DATE('2010-04-01','YYYY-MM-DD') START_DATE, TO_DATE('2013-10-07','YYYY-MM-DD') END_DATE FROM DUAL UNION ALL
SELECT 2, 1,TO_DATE('2013-10-07','YYYY-MM-DD'),TO_DATE('2013-11-30','YYYY-MM-DD') FROM DUAL UNION ALL
SELECT 3,1, TO_DATE('2013-10-07','YYYY-MM-DD'),TO_DATE('3000-12-31','YYYY-MM-DD') FROM DUAL UNION ALL
SELECT 4,2,TO_DATE('2014-01-01','YYYY-MM-DD'), TO_DATE('2014-03-31','YYYY-MM-DD') FROM DUAL UNION ALL
SELECT 5,2,TO_DATE('2014-01-01','YYYY-MM-DD'), TO_DATE('2014-12-31','YYYY-MM-DD') FROM DUAL)
SELECT * FROM T1;
OUTPUT:
COL1 COL2 START_DAT END_DATE
1 1 01-APR-10 07-OCT-13
2 1 07-OCT-13 30-NOV-13
3 1 07-OCT-13 31-DEC-00
4 2 01-JAN-14 31-MAR-14
5 2 01-JAN-14 31-DEC-14
Seems like you look for records whose START_DATE is not matching with the previous record's END_DATE. The logic I have used is (according to your data), the START_DATE of RECORD1=START_DATE of RECORD2. This is what you are looking for. Below is the query.
WITH T1 AS
( SELECT 1 COL1, 1 COL2, TO_DATE('2010-04-01','YYYY-MM-DD') START_DATE, TO_DATE('2013-10-07','YYYY-MM-DD') END_DATE FROM DUAL UNION ALL
SELECT 2, 1,TO_DATE('2013-10-07','YYYY-MM-DD'),TO_DATE('2013-11-30','YYYY-MM-DD') FROM DUAL UNION ALL
SELECT 3,1, TO_DATE('2013-10-07','YYYY-MM-DD'),TO_DATE('3000-12-31','YYYY-MM-DD') FROM DUAL UNION ALL
SELECT 4,2,TO_DATE('2014-01-01','YYYY-MM-DD'), TO_DATE('2014-03-31','YYYY-MM-DD') FROM DUAL UNION ALL
SELECT 5,2,TO_DATE('2014-01-01','YYYY-MM-DD'), TO_DATE('2014-12-31','YYYY-MM-DD') FROM DUAL)
SELECT COL1,COL2,START_DATE,END_DATE FROM(
SELECT COL1,COL2,START_DATE,END_DATE,
LEAD(START_DATE) OVER(PARTITION BY COL2 ORDER BY COL1,COL2) LEAD_COL
FROM T1)
WHERE
START_DATE = LEAD_COL
OR LEAD_COL IS NULL;
OUTPUT:
COL1 COL2 START_DAT END_DATE
2 1 07-OCT-13 30-NOV-13
3 1 07-OCT-13 31-DEC-00
4 2 01-JAN-14 31-MAR-14
5 2 01-JAN-14 31-DEC-14
Method 2 is also considering the condition END_DATE of record1 NOT EQUAL TO START_DATE OF record2.
WITH T1 AS
( SELECT 1 COL1, 1 COL2, TO_DATE('2010-04-01','YYYY-MM-DD') START_DATE, TO_DATE('2013-10-07','YYYY-MM-DD') END_DATE FROM DUAL UNION ALL
SELECT 2, 1,TO_DATE('2013-10-07','YYYY-MM-DD'),TO_DATE('2013-11-30','YYYY-MM-DD') FROM DUAL UNION ALL
SELECT 3,1, TO_DATE('2013-10-07','YYYY-MM-DD'),TO_DATE('3000-12-31','YYYY-MM-DD') FROM DUAL UNION ALL
SELECT 4,2,TO_DATE('2014-01-01','YYYY-MM-DD'), TO_DATE('2014-03-31','YYYY-MM-DD') FROM DUAL UNION ALL
SELECT 5,2,TO_DATE('2014-01-01','YYYY-MM-DD'), TO_DATE('2014-12-31','YYYY-MM-DD') FROM DUAL)
SELECT COL1,COL2,START_DATE,END_DATE FROM(
SELECT COL1,COL2,START_DATE,END_DATE,LAG(END_DATE)OVER(PARTITION BY COL2 ORDER BY COL1,COL2) LAG_COL,
LEAD(START_DATE) OVER(PARTITION BY COL2 ORDER BY COL1,COL2) LEAD_COL
FROM T1)
WHERE
START_DATE!=LAG_COL
OR START_DATE = LEAD_COL
OR LAG_COL IS NOT NULL
OR LEAD_COL IS NULL;
OUTPUT:
COL1 COL2 START_DAT END_DATE
2 1 07-OCT-13 30-NOV-13
3 1 07-OCT-13 31-DEC-00
4 2 01-JAN-14 31-MAR-14
5 2 01-JAN-14 31-DEC-14 -
Can anyone suggest a simple script to delete ~Library/Caches/Firefox evey time a user logs out? I want to trial such a script because the proxy is making Firefox act very starnge and deleting this folder gets it going again . . Thanks very much.
take a look at http://www.bombich.com/mactips/loginhooks.html
-
Need help with SQL Query with Inline View + Group by
Hello Gurus,
I would really appreciate your time and effort regarding this query. I have the following data set.
Reference_No---Check_Number---Check_Date--------Description-------------------------------Invoice_Number----------Invoice_Type---Paid_Amount-----Vendor_Number
1234567----------11223-------------- 7/5/2008----------paid for cleaning----------------------44345563------------------I-----------------*20.00*-------------19
1234567----------11223--------------7/5/2008-----------Adjustment for bad quality---------44345563------------------A-----------------10.00------------19
7654321----------11223--------------7/5/2008-----------Adjustment from last billing cycle-----23543556-------------------A--------------------50.00--------------19
4653456----------11223--------------7/5/2008-----------paid for cleaning------------------------35654765--------------------I---------------------30.00-------------19
Please Ignore '----', added it for clarity
I am trying to write a query to aggregate paid_amount based on Reference_No, Check_Number, Payment_Date, Invoice_Number, Invoice_Type, Vendor_Number and display description with Invoice_type 'I' when there are multiple records with the same Reference_No, Check_Number, Payment_Date, Invoice_Number, Invoice_Type, Vendor_Number. When there are no multiple records I want to display the respective Description.
The query should return the following data set
Reference_No---Check_Number---Check_Date--------Description-------------------------------Invoice_Number----------Invoice_Type---Paid_Amount-----Vendor_Number
1234567----------11223-------------- 7/5/2008----------paid for cleaning----------------------44345563------------------I-----------------*10.00*------------19
7654321----------11223--------------7/5/2008-----------Adjustment from last billing cycle-----23543556-------------------A--------------------50.00--------------19
4653456----------11223--------------7/5/2008-----------paid for cleaning------------------------35654765-------------------I---------------------30.00--------------19
The following is my query. I am kind of lost.
select B.Description, A.sequence_id,A.check_date, A.check_number, A.invoice_number, A.amount, A.vendor_number
from (
select sequence_id,check_date, check_number, invoice_number, sum(paid_amount) amount, vendor_number
from INVOICE
group by sequence_id,check_date, check_number, invoice_number, vendor_number
) A, INVOICE B
where A.sequence_id = B.sequence_id
Thanks,
NickIt looks like it is a duplicate thread - correct me if i'm wrong in this case ->
Need help with SQL Query with Inline View + Group by
Regards.
Satyaki De. -
Help with button code please?
I am a novice and have just completed my first animated movie. I need help with action script.
The movie is currently looped and I have created and invisible button the size of the frame with the intention that a user can click on the movie image to stop it and on second click continue the movie from where it stopped.
I have used the AS event handler method to stop the movie. I have tested it and it works. But I cannot figure suitable code to restart the movie.
Two questions;
1. am I going about the task the right way? (should I use two buttons, one stop, one start)?
2. if my approach is feasible, can anyone give me the correct AS to re-start the movie and put me out of my misery please?you can use the following after changing "yourbutton" and "yourmovieclip" to use suitable instance names:
yourbutton.onRelease=function(){
if(!this.toggle){
yourmovieclip.stop();
} else {
yourmovieclip.play();
this.toggle=!this.toggle; -
Help with access control please
So I'm trying to set up my brother's PSP to the wirless network through MAC address timed access. What I want to do is make it so that he can only access it through certain times in the day. I'm having troubles with actually getting it to work. Everytime I set it up, the PSP only show's up as a DHCP client and not a Wireless client. I tried the option panel with the add wireless clients through the first try access. Could I get some help with this issue please? Thanks!
Just to calm your fears... There is no conspiracy. If someone had an answer or a suggestion they would post it.
-
Please help with SQL amount calulation
-- Results
with t as (
select 'P11877' Mstr_Program, 1 Year_of_study, 'BUSI1490' program_module, 20 no_of_stud, 1 rank, 30 program_credits, 30 cumm_credits from dual union all
select 'P11877', 1, 'COMP1365', 20, 2, 30, 60 from dual union all
select 'P11877', 1, 'BUSI1375', 20, 3, 30, 90 from dual union all
select 'P11877', 1, 'COMP1363', 20, 4, 30, 120 from dual union all
select 'P11877', 2, 'MARK1174', 8, 1, 30, 30 from dual union all
select 'P11877', 2, 'FINA1068', 8, 2, 15, 45 from dual union all
select 'P11877', 2, 'INDU1062', 8, 3, 30, 75 from dual union all
select 'P11877', 2, 'BUSI1329', 8, 4, 15, 90 from dual union all
select 'P11877', 2, 'MARK1138', 8, 5, 30, 120 from dual)
select * from t;-- Each MSTR_PROGRAM can have 1 or many program_module
-- MSTR_PROGRAM's can run for 1 or 2 years (case above is two years) so some modules run in year 1 and some in year 2
-- NO_OF_STUD is the number of students on the module
-- RANK basically ranks the modules by the number of students on them grouped by program and year
-- e.g.row_number() OVER (PARTITION BY Mstr_Program, Year_of_study) ORDER BY COUNT(STUDENT_ID) DESC) rank
-- PROGRAM_CREDITS: each module has a fixed number of credits
-- CUMM_CREDITS: Increments the credit count of modules
-- SUM(program_credits * 10) OVER (PARTITION BY Mstr_Program, Year_of_study
-- ORDER BY count(STUDENT_ID) desc ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) cumm_credits
-- I want to trim of any modules once the CUM_CREDITS hits 120. As seen above. I achieve this by wrapping the main query is another SELECT then LIMIT
-- that WHERE cum_credit <=120.
-- But what I need is:
-- In some cases the the cumm_credit maybe on lets say 90credits then the next module is worth 40 credits. This next module will not show as it
-- will be greater than 120 credits, so i need to pro-rata it:
-- So if credit_count > 120, then the last module is counted pro-rata as follows: 1- ((credit count - 120) / credits from last module
-- Can anyone help with how I can incorporate this into my current code: The SELECT portion of the Original SQL is below: I simplified column names
-- e.t.c in the above so they wont be the same
SELECT * FROM (
SELECT
,SR_PROGRAM Mstr_Program
,DECODE (SORLCUR_YEAR, 1, 1,
2, 2,
3, 3,
4, 3, SR_YEAR) year_of_study
,SCT_SUBJ_CODE||SCT_CRSE_NUMB program_module
,COUNT(student_ID) no_of_stud
,row_number() OVER (PARTITION BY sr_program,
DECODE (sr_year, 1, 1,
2, 2,
3, 3,
4, 3, SR_YEAR) ORDER BY COUNT(student_id) DESC, scbcrse_title asc) rank
,(SCT_CREDIT_HRS * 10) program_credits
,SUM(SCT_CREDIT_HRS * 10) OVER (PARTITION BY sr_program, DECODE (sorlcur_year, 1, 1,
2, 2,
3, 3,
4, 3, SR_YEAR)
ORDER BY count(student_id) desc ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) cumm_credits
WHERE cumm_credit <=120
ORDER BY Mstr_Program, YEAR_OF_STUDY, RANK asc;Maybe
SELECT Mstr_Program,year_of_study,program_module,no_of_stud,rank,program_credits old_program_credits,cumm_credits old_cumm_credits,
case when cumm_credits > 120
then program_credits - cumm_credits + 120
else program_credits
end new_program_credits,
case when cumm_credits > 120
then 120
else cumm_credits
end new_cumm_credits
FROM (SELECT SR_PROGRAM Mstr_Program,
DECODE(SORLCUR_YEAR,1,1,2,2,3,3,4,3,SR_YEAR) year_of_study,
SCT_SUBJ_CODE||SCT_CRSE_NUMB program_module,
COUNT(student_ID) no_of_stud,
row_number() OVER (PARTITION BY sr_program,DECODE(sr_year,1,1,2,2,3,3,4,3,SR_YEAR)
ORDER BY COUNT(student_id) DESC,scbcrse_title) rank,
10 * SCT_CREDIT_HRS program_credits,
10 * SUM(SCT_CREDIT_HRS) OVER (PARTITION BY sr_program,DECODE(sorlcur_year,1,1,2,2,3,3,4,3,SR_YEAR)
ORDER BY count(student_id) desc
ROWS BETWEEN UNBOUNDED PRECEDING AND CURRENT ROW) cumm_credits
WHERE 0 <= case when cumm_credits > 120
then program_credits - cumm_credits + 120
else program_credits
end
ORDER BY Mstr_Program,YEAR_OF_STUDY,RANKRegards
Etbin
Edited by: Etbin on 16.12.2011 8:50
with
t as /* simulating the result achieved */
(select 'P11877' Mstr_Program,1 Year_of_study, 'BUSI1490' program_module,20 no_of_stud,1 rank,30 program_credits,30 cumm_credits from dual union all
select 'P11877', 1, 'COMP1365', 20, 2, 40, 70 from dual union all
select 'P11877', 1, 'BUSI1375', 20, 3, 30, 100 from dual union all
select 'P11877', 1, 'COMP1363', 20, 4, 40, 140 from dual union all
select 'P11877', 2, 'MARK1174', 8, 1, 30, 30 from dual union all
select 'P11877', 2, 'FINA1068', 8, 2, 50, 80 from dual union all
select 'P11877', 2, 'INDU1062', 8, 3, 30, 110 from dual union all
select 'P11877', 2, 'BUSI1329', 8, 4, 50, 160 from dual union all
select 'P11877', 2, 'MARK1138', 8, 5, 30, 190 from dual
select Mstr_Program,Year_of_study,program_module,no_of_stud,rank,program_credits old_credits,cumm_credits old_cumm,
case when cumm_credits > 120
then program_credits - cumm_credits + 120
else program_credits
end new_program_credits,
case when cumm_credits > 120
then 120
else cumm_credits
end new_cumm_credits
from t
where 0 <= case when cumm_credits > 120
then program_credits - cumm_credits + 120
else program_credits
end -
Hi,
I found this Apple script online and here's how it works:
tell application "QuickTime Player"
activate
try
if not (exists document 1) then display dialog "Please open a QuickTime movie." buttons {"Cancel"} default button 1 with icon 1
set thefile to (choose file name)
save document 1 in thefile
close document 1
end try
end tell
+I run the Apple script+
*1. It prompts me to open a movie file in Quicktime*
+I open a movie in Quicktime+
*2. It prompts me for an name and directory to save the new file in*
+I enter a name and directory+
*3. It saves a new reference movie in said directory with said name*
This is useful if I want to customize every file, but unfortunately, I just want to mass create reference movies for a whole bunch of files.
What I am looking for is for an Apple script that is a drag and drop application, so I can drop say 100 movie files or so, and have the Apple script create reference movie files with the same name and in the same directory automatically with no prompts.
Since I am unfamiliar with Apple script I was wondering if someone would be able to edit my existing script to do what I want.
Thanks so much for your help!Use Automator. It's great for repetitious tasks (like the one you've described), and it's very user-friendly. Open Automator, create a new workflow that executes the action you want, and you can apply that action to the resources you wish to edit.
Good resource here:
http://bit.ly/ -
Help With dynamic scripting for Dervied Property
Hi,
I am trying to get the the list of child nodes and then loopthorugh those nodes to do some calculation in a derived propety using dynamic scripting. I tried with below script.
var childEnumerator = node.GetChildEnumerator();
while(childEnumerator.MoveNext())
var propValue = childEnumerator.GetCurrent().PropValue("Custom.Salary");
print(propValue);
While Evaluating this script I am getting below mentioned error. Any idea what i am missing here?
DRM-16008: There was an error calculating Script property Custom.TotalSalaryExp for EMP_Zone/Emp/PPD1: TypeError: 'GetChildEnumerator' is not a function
Please help me out. thanks fr your co-operation
Regards,
SudiptaTry this instead...
var childEnumerator = node.GetChildEnumerator();
childEnumerator.MoveNext();
while(childEnumerator.GetCurrent() != null)
var propValue = childEnumerator.GetCurrent().PropValue("Custom.Salary");
print(propValue);
childEnumerator.MoveNext();
Maybe you are looking for
-
Calendar month view dots on every day...
I seem to have a dot in every day of every month in month view. I have seen pics of other folks who only have dots in the days where there is an event. So I am thinking there is something wrong with my sync. I downloaded 7.3.1 iTunes, resynced, and e
-
I want to sync to iPod but when I check songs I want to sync, will they automatically sync to iPad? I want the songs on iPod only.
-
Should I make a back up of the website folder on iDisk? Is this folder the same as the Domain.sites2 folder in the Library? Is it the same as the folder that's created when I click Publish to Folder in iWeb? It's so confusing - from where should I
-
Premiere Pro cs4 Windows 7 64bit 再インストールの途中で以下のウインドが出て先に進めません
お世話になります. 以下の場所で CS4製品のダウンロード をしている途中で上の図が出て先に進むことが出来ません. どうしたらいいか教えて下さい. よろしくお願いします.
-
What is best password AP to sync with Imac (Snow Leopard)?
What is best password AP to sync with Imac (Snow Leopard)?