How Can I Make This Sql Query To Load Data Correctly (sql server)?

Hi guys
I have a datagridview where the third column is a custom column with all days
of a month. It takes data with a query who distinct the column Improve.
Here is the code :
Private Sub fill_impro()
dgImprove.Rows.Clear()
Try
Dim i As Integer = 0
Dim query As String = "SELECT Improve,Price,Active,Idate FROM (SELECT Improve,Price,Active,Idate, ROW_NUMBER() OVER (PARTITION BY Price ORDER BY Price) AS rn FROM tblImprove) tmp WHERE rn = 1"
cmd = New SqlCommand(query, clsMSSQL.con)
myDR = cmd.ExecuteReader
If myDR.HasRows Then
While myDR.Read
dgImprove.Rows.Add()
dgImprove.Rows(i).Cells(0).Value = myDR.GetDecimal(myDR.GetOrdinal("Price"))
dgImprove.Rows(i).Cells(1).Value = myDR.GetString(myDR.GetOrdinal("Improve"))
Dim myday As Integer = DatePart(DateInterval.Day, myDR.GetValue(myDR.GetOrdinal("Idate")))
dgImprove.Rows(i).Cells(myday + 1).Value = myDR.GetInt32(myDR.GetOrdinal("Active"))
i = i + 1
End While
End If
myDR.Close()
Catch ex As Exception
MsgBox(ex.Message, MsgBoxStyle.Critical, "Σφάλμα")
End Try
End Sub
And here is the result :
http://i60.tinypic.com/28gwf83.jpg
The column Active value is 1.
The problem is that column Active values are missing (red values in image).
How can i fix that ?
Thanks in advance

try like this
Dim Price As Decimal
Dim improve As String = String.Empty
While myDR.Read
Dim myday As Integer = DatePart(DateInterval.Day, myDR.GetValue(myDR.GetOrdinal("Idate")))
If Not (myDR.GetDecimal(myDR.GetOrdinal("Price")) = Price And myDR.GetString(myDR.GetOrdinal("Improve")) = improve) Then
i += 1
dgimprove.Rows.Add()
dgimprove.Rows(i).Cells(0).Value = myDR.GetDecimal(myDR.GetOrdinal("Price"))
dgimprove.Rows(i).Cells(1).Value = myDR.GetString(myDR.GetOrdinal("Improve"))
Price = myDR.GetDecimal(myDR.GetOrdinal("Price"))
improve = myDR.GetString(myDR.GetOrdinal("Improve"))
End If
dgimprove.Rows(i).Cells(myday + 1).Value = myDR.GetInt32(myDR.GetOrdinal("Active"))
End While
and change your sql statement to just
SELECT Improve,Price,Active,Idate FROM tblImprove WHERE Active = 1

Similar Messages

  • How Can I Make This Sql Query To Load Data Correctly (sql server 2014)?

    Hi guys
    I have a datagridview where the third column is a custom column with all days
    of a month. It takes data with a query who distinct the column Improve.
    SELECT Improve,Price,Active,Idate FROM (SELECT Improve,Price,Active,Idate, ROW_NUMBER() OVER (PARTITION BY Improve ORDER BY Improve) AS rn FROM tblImprove) tmp WHERE rn = 1
    And here is the result :
    http://i60.tinypic.com/28gwf83.jpg
    The column Active value is 1.
    The problem is that column Active values are missing (red values in image).
    How can i fix that ?
    Thanks in advance
     

    Hi, 
    Maybe you can try below code, I have changed the order by of the row_number(). Therefore it will sort on the date, and you will get the first date icm with improve cell. If this is not what you are looking for, please explain what the output should be. 
    SELECT Improve,Price,Active,Idate
    FROM
    SELECT Improve,Price,Active,Idate, ROW_NUMBER() OVER (PARTITION BY Improve ORDER BY ldate) AS rn
    FROM tblImprove
    ) tmp WHERE rn = 1
    Regards, 
    Reshma
    Please Vote as Helpful if an answer is helpful and/or Please mark Proposed as Answer or Mark As Answer when question is answered

  • How can I make this complex query?

    I don’t know how can I do this complex query...
    I have the tables Customers, Vehicles and Models. A customer can have 0-N Vehicles and a vehicle have 1 Model.
    Customers: ID_Customer (PK), Name, LastName...
    Vehicles: ID_Vehicle (PK), ID_Customer, ID_Model, date_sale
    Models: ID_Modelo (PK), Model_Name
    Then I need to know the buy average time (date_sale) between 2 models (ID_Model)
    For example I have these Vehicles:
    ID_Vehicle (PK)...ID_Customer...ID_Model....date_sale
    1................................123....................1.............21/05/2000
    2................................459....................3............ 16/08/2000
    3................................123....................2............ 28/06/2001
    4................................516....................1............ 09/09/2001
    5................................459....................4............ 18/10/2002
    6................................516....................2............ 20/12/2002
    If I want to know the buy average time (date_sale) between ID_Model 1 and ID_Model 2 it is. (403 + 467) / 2 = 435 days !!!
    * Customer 123 (model 1 to 2): 25/06/2001 – 21/05/2000 ==> 403 days
    * Customer 516 (model 1 to 2): 01/12/2002 – 01/05/2000 ==> 467 days.
    I need to do the query for all the combination models. For example If I have the Models 1, 2 and 3 I need to obtain:
    Source_Model.....Target_Model....Buy_Average_Time
    1......................................1....................... xxx days
    1......................................2....................... xxx days
    1......................................3....................... xxx days
    2......................................1....................... xxx days
    2......................................2....................... xxx days
    2......................................3....................... xxx days
    3......................................1....................... xxx days
    3......................................2....................... xxx days
    3......................................3....................... xxx days
    If it is necessary I could create a table with the fields Source_Model, Target_Model and Buy_Average_Time for accelerate the query time response.
    But how can I do this query??????????
    Thanks very much!!!

    Hi,
    Thanks for your reply but It is not correct for me because the Customer could have several vehicles in her life.
    If I make the query with my examples data it is OK
    ID_Vehicle (PK)...ID_Customer...ID_Model....date_sale
    1................................123....................1.............21/05/2000
    2................................459....................3............ 16/08/2000
    3................................123....................2............ 28/06/2001
    4................................516....................1............ 09/09/2001
    5................................459....................4............ 18/10/2002
    6................................516....................2............ 20/12/2002
    select v1.id_model as source_model,
    v2.id_model as target_model,
    avg (v2.date_sale - v1.date_sale) || ' days' as buy_average_time
    from vehicles v1,
    vehicles v2
    where v1.id_customer = v2.id_customer
    and v2.date_sale > v1.date_sale
    group by v1.id_model, v2.id_model;
    I received:
    SOURCE_MODEL     TARGET_MODEL     BUY_AVERAGE_TIME
    ..............1................................2.....................................435 days
    ..............3................................4.....................................793 days
    But If I insert a new vehicle:
    ID_Vehicle (PK)...ID_Customer...ID_Model....date_sale
    7................................516....................3............ 16/08/2003
    And I execute the query now I receive:
    SOURCE_MODEL     TARGET_MODEL     BUY_AVERAGE_TIME
    ..............1................................2...........................435 days
    ..............1................................3...........................706 days
    ..............2................................3...........................239 days
    ..............3................................4...........................793 days
    It is NO correct because I don’t have the 1 (Source_model) to 3 (Target_model) combination in the Vehicles data!!! (I have 1 to 2 and 2 to 3 but NO 1 to 3!!!!).
    Then the query is not OK for me!
    Besides If I modify the Vehicle 7 data and put ID_Model = 2:
    ID_Vehicle (PK)...ID_Customer...ID_Model....date_sale
    7................................516....................2............ 16/08/2003
    I received:
    SOURCE_MODEL     TARGET_MODEL     BUY_AVERAGE_TIME
    ..............1................................2...........................525,33 days
    ..............2................................2...........................239 days
    ..............3................................4...........................793 days
    It is NO correct because the BUY_AVERAGE_TIME for 1 to 2 combination is 435 days (the same of the original query) because I aggregate only the combination 2 to 2 with the ID_VEHICLE 7
    Below I attach the examples scripts.
    Could you help me with this query, please?
    Thanks very much!
    CREATE TABLE VEHICLES
    ID_VEHICLE NUMBER(9),
    ID_CUSTOMER NUMBER(9),
    ID_MODEL NUMBER(9),
    DATE_SALE DATE
    TABLESPACE USERS
    PCTUSED 0
    PCTFREE 10
    INITRANS 1
    MAXTRANS 255
    STORAGE (
    INITIAL 64K
    MINEXTENTS 1
    MAXEXTENTS 2147483645
    PCTINCREASE 0
    BUFFER_POOL DEFAULT
    LOGGING
    NOCACHE
    NOPARALLEL;
    INSERT INTO VEHICLES ( ID_VEHICLE, ID_CUSTOMER, ID_MODEL, DATE_SALE ) VALUES (
    1, 123, 1, TO_Date( '05/21/2000 12:00:00 AM', 'MM/DD/YYYY HH:MI:SS AM'));
    INSERT INTO VEHICLES ( ID_VEHICLE, ID_CUSTOMER, ID_MODEL, DATE_SALE ) VALUES (
    2, 459, 3, TO_Date( '08/16/2000 12:00:00 AM', 'MM/DD/YYYY HH:MI:SS AM'));
    INSERT INTO VEHICLES ( ID_VEHICLE, ID_CUSTOMER, ID_MODEL, DATE_SALE ) VALUES (
    3, 123, 2, TO_Date( '06/28/2001 12:00:00 AM', 'MM/DD/YYYY HH:MI:SS AM'));
    INSERT INTO VEHICLES ( ID_VEHICLE, ID_CUSTOMER, ID_MODEL, DATE_SALE ) VALUES (
    4, 516, 1, TO_Date( '09/09/2001 12:00:00 AM', 'MM/DD/YYYY HH:MI:SS AM'));
    INSERT INTO VEHICLES ( ID_VEHICLE, ID_CUSTOMER, ID_MODEL, DATE_SALE ) VALUES (
    5, 459, 4, TO_Date( '10/18/2002 12:00:00 AM', 'MM/DD/YYYY HH:MI:SS AM'));
    INSERT INTO VEHICLES ( ID_VEHICLE, ID_CUSTOMER, ID_MODEL, DATE_SALE ) VALUES (
    6, 516, 2, TO_Date( '12/20/2002 12:00:00 AM', 'MM/DD/YYYY HH:MI:SS AM'));
    INSERT INTO VEHICLES ( ID_VEHICLE, ID_CUSTOMER, ID_MODEL, DATE_SALE ) VALUES (
    7, 516, 2, TO_Date( '08/16/2003 12:00:00 AM', 'MM/DD/YYYY HH:MI:SS AM'));
    COMMIT;
    CREATE TABLE MODELS
    ID_MODELO NUMBER(9),
    MODEL_NAME VARCHAR2(25 BYTE)
    TABLESPACE USERS
    PCTUSED 0
    PCTFREE 10
    INITRANS 1
    MAXTRANS 255
    STORAGE (
    INITIAL 64K
    MINEXTENTS 1
    MAXEXTENTS 2147483645
    PCTINCREASE 0
    BUFFER_POOL DEFAULT
    LOGGING
    NOCACHE
    NOPARALLEL;
    INSERT INTO MODELS ( ID_MODELO, MODEL_NAME ) VALUES (
    1, 'MODEL 1');
    INSERT INTO MODELS ( ID_MODELO, MODEL_NAME ) VALUES (
    2, 'MODEL 2');
    INSERT INTO MODELS ( ID_MODELO, MODEL_NAME ) VALUES (
    3, 'MODEL 3');
    INSERT INTO MODELS ( ID_MODELO, MODEL_NAME ) VALUES (
    4, 'MODEL 4');
    COMMIT;
    CREATE TABLE CUSTOMERS
    ID_CUSTOMER NUMBER(9),
    NAME VARCHAR2(25 BYTE),
    LASTNAME VARCHAR2(25 BYTE)
    TABLESPACE USERS
    PCTUSED 0
    PCTFREE 10
    INITRANS 1
    MAXTRANS 255
    STORAGE (
    INITIAL 64K
    MINEXTENTS 1
    MAXEXTENTS 2147483645
    PCTINCREASE 0
    BUFFER_POOL DEFAULT
    LOGGING
    NOCACHE
    NOPARALLEL;
    INSERT INTO CUSTOMERS ( ID_CUSTOMER, NAME, LASTNAME ) VALUES (
    123, 'Customer 123', 'A');
    INSERT INTO CUSTOMERS ( ID_CUSTOMER, NAME, LASTNAME ) VALUES (
    459, 'Customer 459', 'B');
    INSERT INTO CUSTOMERS ( ID_CUSTOMER, NAME, LASTNAME ) VALUES (
    516, 'Customer 516', 'C');
    INSERT INTO CUSTOMERS ( ID_CUSTOMER, NAME, LASTNAME ) VALUES (
    318, 'Customer 318', 'D');
    COMMIT;

  • How can i join this two query?

    I have two table table employee and CSEReduxResponses
    In table employee i have
    CREATE TABLE [dbo].[employee](
    [emp_id] [int] IDENTITY(1,1) NOT NULL,
    [emp_namefirst] [varchar](255) NOT NULL,
    [emp_namemiddle] [varchar](50) NULL,
    [emp_namelast] [varchar](255) NOT NULL
    on responds i have 
    CREATE TABLE [dbo].[CSEReduxResponses](
    [response_id] [int] IDENTITY(1,1) NOT NULL,
    [employee] [int] NOT NULL,
    [employeedept] [int] NOT NULL,
    [star] [tinyint] NOT NULL,
    [status] [int] NOT NULL,
    [approvedby] [int] NULL,
    [approveddate] [datetime] NULL,
    [execoffice_status] [int] NULL,
    Im trying to get the employee with the MAX execpffice_status( this is either a 1 or 0).
    i have this query that i made for it
    select top(1) with ties employee, SUM(execoffice_status) as 'total'
    from   CSEReduxResponses
    group by employee
    order by 'total' desc
    my query for employee table is 
       select emp_namefirst as first , emp_namelast as [last]
    from phonelist.dbo.employee where emp_namefirst is not null
    How can i get this 2 query together so i can output the employee (first and last )name
    with the max exeoffice_status?
    i use :
    Microsoft SQL Server Management Studio 10.0.2531.0
    ps: sorry if i put this is the wrong forum, this is my first time here and first post.

    Are you looking for the below?
    CREATE TABLE [dbo].[employee](
    [emp_id] [int] IDENTITY(1,1) NOT NULL,
    [emp_namefirst] [varchar](255) NOT NULL,
    [emp_namemiddle] [varchar](50) NULL,
    [emp_namelast] [varchar](255) NOT NULL
    Insert into Employee Values('abc','bcd','cdf')
    Insert into Employee Values('xyz','yxw','xwv')
    CREATE TABLE [dbo].[CSEReduxResponses](
    [response_id] [int] IDENTITY(1,1) NOT NULL,
    [employee] [int] NOT NULL,
    [employeedept] [int] NOT NULL,
    [star] [tinyint] NOT NULL,
    [status] [int] NOT NULL,
    [approvedby] [int] NULL,
    [approveddate] [datetime] NULL,
    [execoffice_status] [int] NULL,
    Insert into [CSEReduxResponses]( employee,employeedept,star,status,approvedby,approveddate,execoffice_status)
    Values(1,100,1,1,1,GETDATE(),0),
    (1,100,1,1,1,GETDATE(),1),
    (2,100,1,1,1,GETDATE(),0)
    ;With cte as( Select *,SUM([execoffice_status]) over(partition by Employee) sumstatus From [CSEReduxResponses] )
    Select Distinct A.*,B.sumstatus
    From Employee A
    Inner Join cte B On A.emp_id = B.employee
    --OR
    ;With cte as( Select employee ,SUM([execoffice_status]) sumstatus From [CSEReduxResponses] group by Employee)
    Select Distinct A.*,(Select sumstatus From cte B where A.emp_id = B.employee)
    From Employee A
    Drop table Employee,[CSEReduxResponses]

  • How Can I make the following query faster

    Hi Guru
    I want your valuable suggestion to make the following query faster.I did not write all required columns list. I gave here all those columns where I have conditon like decode,case when,or subquery
    (SELECT CASE WHEN REPORTED_BY IS NULL THEN
              (SELECT INITCAP(EMP_NAME) FROM HR_EMP WHERE EMP_NO = M.EMP_NO_RADIO)
         ELSE (SELECT INITCAP(EMP_NAME) FROM HR_EMP WHERE EMP_NO = M.REPORTED_BY) END RADIOLOGIST_NAME,
         (SELECT TEAM_NAME FROM DC_TECHTEAMMST WHERE TEAM_NO = M.GROUP_NO) GROUP_NAME,
         CASE WHEN M.RESULT_ENTRY_LOCK_BY IS NOT NULL THEN 'R'
    WHEN M.REPORT_DONE = 'D' THEN 'D'
    WHEN M.REPORT_DONE = 'P' THEN 'P'
    WHEN M.REPORT_DONE = 'F' THEN 'F'
         WHEN NVL(M.IMG_CAPTURED,'X') NOT IN ('B','Y') OR M.QA_RESULT = 'F' THEN 'S'
    WHEN NVL(M.IMG_CAPTURED,'X') IN ('B','Y') AND NVL(M.QA_RESULT,'X') NOT IN ('B','P') THEN 'Q'
         wHEN NVL(M.IMG_CAPTURED,'X') IN ('B','Y') AND NVL(M.QA_RESULT,'X') IN ('B','P') THEN 'C'
    END STATUS,
         (SELECT DECODE(NVL(V.DELIVERY_STATUS,'N'),'E',3,'U',2,1)
              FROM FN_VOUCHERCHD V WHERE V.VOUCHER_NO = M.VOUCHER_NO AND V.ITEM_NO = M.TEST_NO) DELIVERY_STATUS,
         trunc((start_time-order_end)*24,0)||' hr'||':'||
         decode(length(trunc(to_char(MOD((M.start_time-M.order_end)*24,1)*60),0)),2,to_char(trunc(to_char(MOD((M.start_time-M.order_end)*24,1)*60),0))
              ,1,to_char('0'||trunc(to_char(MOD((M.start_time-M.order_end)*24,1)*60),0)))||' mi' duration_order_capture,
         DECODE(R.CONFIDENTIAL_PATIENT,'Y','*',NVL(R.NAME,R.name_lang_name||' '||R.name_lang_fname)) PAT_NAME,
         FNC_PATIENTAGE(R.REG_NO,'',R.CONFIDENTIAL_PATIENT) pat_age,
         DECODE(R.CONFIDENTIAL_PATIENT,'Y','*',R.PATIENT_SEX) PAT_SEX
    FROM DC_MODALITYAPPOINTMENT M,DC_TESTMST T,OP_REGISTRATION R
    WHERE M.ACCESSION_NO IS NOT NULL AND NVL(M.CANCEL_FLAG,'N') = 'N'
    AND (NVL(T.SP_GEN,'S') = 'S' OR NVL(M.DOC_REQ_GEN,'N') = 'Y')
    AND M.TEST_NO IS NOT NULL AND M.TEST_NO = T.TEST_NO AND M.REG_NO = R.REG_NO)
    How can I make the above query faster.
    Query condition or indexing whatever is preferable please guide me.
    The approximate data of tables
    DC_MODALITYAPPOINTMENT 2,000,000
    A lot of updating is going on some columns of this table.all columns are not in the select list, Insertion is happend in batch process by back-end trigger of another table.
    Primary key based one column,
    OP_REGISTRATION 500,000
    Daily insertion on this table around 500 records,updation is not much.
    Primary key based one column 'reg_no'
    DC_TESTMST
    Total records of this table not more than 1500.This is setup table. Insertion and updation is not much on this table also
    I have to create a view based on this query .
    and I have to create another view to serve another purpose.
    In the 2nd view I need this query as well as I need another query by using union all operator based on a table(dc_oldresult)
    which have 1,600,000 records.There is no DML on this table
    SELECT      NVL((SELECT USER_DEFINE_TEST_NO FROM DC_TESTMST WHERE TEST_NO = SV_ID AND ROWNUM = 1 ),SV_ID) USER_D_EXAM_NO,
    (SELECT TEST_TYPE FROM DC_TESTMST WHERE TEST_NO = SV_ID AND ROWNUM = 1 ) EXAM_TYPE,
         NVL((SELECT TEST_NAME FROM DC_TESTMST WHERE TEST_NO = SV_ID AND ROWNUM = 1),'Exam Code: '||sv_id) EXAM_NAME,
         (SELECT PAT_NAME FROM OP_REGISTRATION WHERE REG_NO = HN) PATIENT_NAME,
         (SELECT PAT_AGE FROM OP_REGISTRATION WHERE REG_NO = HN) PATIENT_AGE,
         (SELECT PAT_SEX FROM OP_REGISTRATION WHERE REG_NO = HN) PATIENT_GENDER
    FROM DC_OLDRESULT
    WHERE HN IS NOT NULL AND SV_ID IS NOT NULL AND UPPER(ACTIVE) = 'TRUE'
    Should I make join DC_OLDRESULT, OP_REGISTRATION and DC_TESTMST? or The eixisting subquery is better?
    I use OP_REGISTRATION and DC_TESTMST in both query
    Thanks in advance
    Mokarem

    When your query takes too long ...

  • How can I make this join in ADF and make CRUD operation in this

    How to make this relation in ADF
    I have table employees and this is my master table
    Table Name: Employees
    Columns:
    Employee_id(PK)
    Employee_name
    Employee_Salary
    I have a child table that is called related employee that contains employees related to this employee
    Table_name: Related_Employee
    Columns:
    Related_Employee_Table_Id(PK)
    Employee_id(FK)
    Related_Employee_Id
    When I open employee id = 100 for example and add related employee id = 10
    this is added with no problem but the requirement is that when I open employee 10 I find employee id 100 as related employee
    How can I make this scenario.

    The best way to understand this is to look at an example. If you are using an oracle database such as XE for you have a schema called hr. This shema has a number of tables two of which are departments and employees. a department has multiple employees correct. So in your example a employee may be related to x # of other employees perhaps. A very similar scenario as that in the hr Schema. If you don't have an Oracle XE database, download one from here -> http://www.oracle.com/technetwork/database/express-edition/downloads/index.html
    Create Business Components off of the Departments and Employees schema and you'll see that due to the db design, you get what you're talking about for free (i.e. the join). Thus, you have the master-detail relationship you're looking for. For a quick tip, here is the relationship between departments and employees in the hr schema via a create script that you can exam with data inserts included:
    SET SQLBLANKLINES ON
    CREATE TABLE DEPARTMENTS
    DEPARTMENT_ID NUMBER(4, 0) NOT NULL
    , DEPARTMENT_NAME VARCHAR2(30 BYTE) NOT NULL
    , MANAGER_ID NUMBER(6, 0)
    , LOCATION_ID NUMBER(4, 0)
    , CONSTRAINT DEPT_ID_PK PRIMARY KEY
    DEPARTMENT_ID
    USING INDEX
    CREATE UNIQUE INDEX DEPT_ID_PK ON DEPARTMENTS (DEPARTMENT_ID ASC)
    LOGGING
    TABLESPACE "USERS"
    PCTFREE 10
    INITRANS 2
    STORAGE
    INITIAL 65536
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    BUFFER_POOL DEFAULT
    ENABLE
    LOGGING
    TABLESPACE "USERS"
    PCTFREE 10
    INITRANS 1
    STORAGE
    INITIAL 65536
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    BUFFER_POOL DEFAULT
    CREATE TABLE EMPLOYEES
    EMPLOYEE_ID NUMBER(6, 0) NOT NULL
    , FIRST_NAME VARCHAR2(20 BYTE)
    , LAST_NAME VARCHAR2(25 BYTE) NOT NULL
    , EMAIL VARCHAR2(25 BYTE) NOT NULL
    , PHONE_NUMBER VARCHAR2(20 BYTE)
    , HIRE_DATE DATE NOT NULL
    , JOB_ID VARCHAR2(10 BYTE) NOT NULL
    , SALARY NUMBER(8, 2)
    , COMMISSION_PCT NUMBER(2, 2)
    , MANAGER_ID NUMBER(6, 0)
    , DEPARTMENT_ID NUMBER(4, 0)
    , CONSTRAINT EMP_EMP_ID_PK PRIMARY KEY
    EMPLOYEE_ID
    USING INDEX
    CREATE UNIQUE INDEX EMP_EMP_ID_PK ON EMPLOYEES (EMPLOYEE_ID ASC)
    LOGGING
    TABLESPACE "USERS"
    PCTFREE 10
    INITRANS 2
    STORAGE
    INITIAL 65536
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    BUFFER_POOL DEFAULT
    ENABLE
    LOGGING
    TABLESPACE "USERS"
    PCTFREE 10
    INITRANS 1
    STORAGE
    INITIAL 65536
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    BUFFER_POOL DEFAULT
    CREATE INDEX DEPT_LOCATION_IX ON DEPARTMENTS (LOCATION_ID ASC)
    LOGGING
    TABLESPACE "USERS"
    PCTFREE 10
    INITRANS 2
    STORAGE
    INITIAL 65536
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    BUFFER_POOL DEFAULT
    CREATE INDEX EMP_DEPARTMENT_IX ON EMPLOYEES (DEPARTMENT_ID ASC)
    LOGGING
    TABLESPACE "USERS"
    PCTFREE 10
    INITRANS 2
    STORAGE
    INITIAL 65536
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    BUFFER_POOL DEFAULT
    CREATE INDEX EMP_JOB_IX ON EMPLOYEES (JOB_ID ASC)
    LOGGING
    TABLESPACE "USERS"
    PCTFREE 10
    INITRANS 2
    STORAGE
    INITIAL 65536
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    BUFFER_POOL DEFAULT
    CREATE INDEX EMP_MANAGER_IX ON EMPLOYEES (MANAGER_ID ASC)
    LOGGING
    TABLESPACE "USERS"
    PCTFREE 10
    INITRANS 2
    STORAGE
    INITIAL 65536
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    BUFFER_POOL DEFAULT
    CREATE INDEX EMP_NAME_IX ON EMPLOYEES (LAST_NAME ASC, FIRST_NAME ASC)
    LOGGING
    TABLESPACE "USERS"
    PCTFREE 10
    INITRANS 2
    STORAGE
    INITIAL 65536
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    BUFFER_POOL DEFAULT
    ALTER TABLE EMPLOYEES
    ADD CONSTRAINT EMP_EMAIL_UK UNIQUE
    EMAIL
    USING INDEX
    CREATE UNIQUE INDEX EMP_EMAIL_UK ON EMPLOYEES (EMAIL ASC)
    LOGGING
    TABLESPACE "USERS"
    PCTFREE 10
    INITRANS 2
    STORAGE
    INITIAL 65536
    MINEXTENTS 1
    MAXEXTENTS UNLIMITED
    BUFFER_POOL DEFAULT
    ENABLE;
    ALTER TABLE DEPARTMENTS
    ADD CONSTRAINT DEPT_LOC_FK FOREIGN KEY
    LOCATION_ID
    REFERENCES LOCATIONS
    LOCATION_ID
    ENABLE;
    ALTER TABLE DEPARTMENTS
    ADD CONSTRAINT DEPT_MGR_FK FOREIGN KEY
    MANAGER_ID
    REFERENCES EMPLOYEES
    EMPLOYEE_ID
    ENABLE;
    ALTER TABLE EMPLOYEES
    ADD CONSTRAINT EMP_DEPT_FK FOREIGN KEY
    DEPARTMENT_ID
    REFERENCES DEPARTMENTS
    DEPARTMENT_ID
    ENABLE;
    ALTER TABLE EMPLOYEES
    ADD CONSTRAINT EMP_JOB_FK FOREIGN KEY
    JOB_ID
    REFERENCES JOBS
    JOB_ID
    ENABLE;
    ALTER TABLE EMPLOYEES
    ADD CONSTRAINT EMP_MANAGER_FK FOREIGN KEY
    MANAGER_ID
    REFERENCES EMPLOYEES
    EMPLOYEE_ID
    ENABLE;
    ALTER TABLE DEPARTMENTS
    ADD CONSTRAINT DEPT_NAME_NN CHECK
    (DEPARTMENT_NAME IS NOT NULL)
    ENABLE;
    ALTER TABLE EMPLOYEES
    ADD CONSTRAINT EMP_EMAIL_NN CHECK
    (EMAIL IS NOT NULL)
    ENABLE;
    ALTER TABLE EMPLOYEES
    ADD CONSTRAINT EMP_HIRE_DATE_NN CHECK
    (HIRE_DATE IS NOT NULL)
    ENABLE;
    ALTER TABLE EMPLOYEES
    ADD CONSTRAINT EMP_JOB_NN CHECK
    (JOB_ID IS NOT NULL)
    ENABLE;
    ALTER TABLE EMPLOYEES
    ADD CONSTRAINT EMP_LAST_NAME_NN CHECK
    (LAST_NAME IS NOT NULL)
    ENABLE;
    ALTER TABLE EMPLOYEES
    ADD CONSTRAINT EMP_SALARY_MIN CHECK
    (SALARY > 0)
    ENABLE;
    COMMENT ON TABLE DEPARTMENTS IS 'Departments table that shows details of departments where employees
    work. Contains 27 rows; references with locations, employees, and job_history tables.';
    COMMENT ON TABLE EMPLOYEES IS 'employees table. Contains 107 rows. References with departments,
    jobs, job_history tables. Contains a self reference.';
    COMMENT ON COLUMN DEPARTMENTS.DEPARTMENT_ID IS 'Primary key column of departments table.';
    COMMENT ON COLUMN DEPARTMENTS.DEPARTMENT_NAME IS 'A not null column that shows name of a department. Administration,
    Marketing, Purchasing, Human Resources, Shipping, IT, Executive, Public
    Relations, Sales, Finance, and Accounting. ';
    COMMENT ON COLUMN DEPARTMENTS.MANAGER_ID IS 'Manager_id of a department. Foreign key to employee_id column of employees table. The manager_id column of the employee table references this column.';
    COMMENT ON COLUMN DEPARTMENTS.LOCATION_ID IS 'Location id where a department is located. Foreign key to location_id column of locations table.';
    COMMENT ON COLUMN EMPLOYEES.EMPLOYEE_ID IS 'Primary key of employees table.';
    COMMENT ON COLUMN EMPLOYEES.FIRST_NAME IS 'First name of the employee. A not null column.';
    COMMENT ON COLUMN EMPLOYEES.LAST_NAME IS 'Last name of the employee. A not null column.';
    COMMENT ON COLUMN EMPLOYEES.EMAIL IS 'Email id of the employee';
    COMMENT ON COLUMN EMPLOYEES.PHONE_NUMBER IS 'Phone number of the employee; includes country code and area code';
    COMMENT ON COLUMN EMPLOYEES.HIRE_DATE IS 'Date when the employee started on this job. A not null column.';
    COMMENT ON COLUMN EMPLOYEES.JOB_ID IS 'Current job of the employee; foreign key to job_id column of the
    jobs table. A not null column.';
    COMMENT ON COLUMN EMPLOYEES.SALARY IS 'Monthly salary of the employee. Must be greater
    than zero (enforced by constraint emp_salary_min)';
    COMMENT ON COLUMN EMPLOYEES.COMMISSION_PCT IS 'Commission percentage of the employee; Only employees in sales
    department elgible for commission percentage';
    COMMENT ON COLUMN EMPLOYEES.MANAGER_ID IS 'Manager id of the employee; has same domain as manager_id in
    departments table. Foreign key to employee_id column of employees table.
    (useful for reflexive joins and CONNECT BY query)';
    COMMENT ON COLUMN EMPLOYEES.DEPARTMENT_ID IS 'Department id where employee works; foreign key to department_id
    column of the departments table';

  • I have an ipad mini. From one moment to another a document that was created and used on pages app ( on the ipad mini) does not want to open ( When pressed it states " document cant be opened). How can I make this document open again?

    I have an ipad mini. From one moment to another a document that was created and used on pages app ( on the ipad mini) does not want to open ( When pressed it states " document cant be opened). How can I make this document open again?
    I have tried back ups and  restoring, resetting, and even updating the pages app. And nothing has worked.

    I have an ipad mini. From one moment to another a document that was created and used on pages app ( on the ipad mini) does not want to open ( When pressed it states " document cant be opened). How can I make this document open again?
    I have tried back ups and  restoring, resetting, and even updating the pages app. And nothing has worked.

  • I keep Mail open on my MacBook Pro and prior to Mavericks items would open on my 27" secondary display. How can I make this happen in Mavericks?

    I keep Mail open on my MacBook Pro and prior to Mavericks items would open on my 27" secondary display. How can I make this happen in Mavericks?

    In System Preferences > Mission Control, uncheck mark Displays have seperate windows. This should bring you back to the secondary display you had before the upgrade. You may have to open Mail, the first time and place it on your secondary display. You also won't have the advantages of the dock and menus on the secondary display.
    I keep my own secondary display with these settings because I need the ability to expand a window across both displays.

  • When filling out a form, some fields copy to others when I tab to the next. How can I make this stop?

    When filling out a form, some fields copy to others when I tab to the next. How can I make this stop?

    You can't using Adobe Reader. It looks like whomever created the form used the same identifiers (names) for various fields. Each field with the same name will populate with the information used in another field of the same name. This is intentional.
    Normally when I see this, it tells me that someone created an initial field then copy/pasted it to make additional fields but forgot to change the names.

  • Just restored my iPhone from iCloud. My wife and I have always shared one iCloud ID. But since my restore, when a call comes in, it rings on both my phone and hers. How can I make this stop?

    Just restored my iPhone 5  from iCloud. My wife and I have always shared one iCloud ID. But since my restore, when a call comes in, it rings on both my phone and hers. How can I make this stop?  We had it all set up fine before the restore, and there was a trick to it in the settings.  I've noticed that since my restore, her phone has picked up what looks like the symbol of a phone in the upper right corner of the display, right next to the Bluetooth symbol.

    Hi Big Slick,
    Welcome to the Apple Support Community!
    It sounds like your iPhones may be using a new feature in iOS 8 called Continuity. The following article and information explains how to set up this feature for phone calls. You can review the information on the setup to reverse this effect. My suggestion would be to turn off FaceTime on one of the devices.
    Connect your iPhone, iPad, iPod touch, and Mac using Continuity
    Phone calls
    With Continuity, you can make and receive cellular phone calls from your iPad, iPod touch, or Mac when your iPhone is on the same Wi-Fi network.
    To make and receive phone calls, here's what you need:
    Sign in to the same iCloud account on all your devices, including your Mac.
    Your iPhone and your iPad or iPod touch need to use iOS 8 or later. Your Mac needs to use OS X Yosemite.
    All devices must be on the same Wi-Fi network.
    All devices must be signed in to FaceTime using the same iCloud account. This means any device that shares your Apple ID will get your phone calls. Look below for instructions on how to turn off iPhone cellular calls.
    Wi-Fi Calling needs to be off. Go to Settings > Phone. If you see Wi-Fi Calling, turn it off.
    Cheers,
    Joe

  • Whenever I open the browser, the check plugins page always opens in a second tab. How can I make this stop?

    Whenever I open my browser, the check plugins page keeps opening, even after I have updated all of my plugins.
    How can I make this stop?

    That is a bug with blocklisting plugins that has been fixed.<br />
    You can correct this issue by forcing the file blocklist.xml to update or wait until Firefox updates the file.<br />
    That update will remove the severity="0" flags in the file that cause the problem.
    See:
    * [/questions/832793?page=2#answer-198407]
    * http://forums.mozillazine.org/viewtopic.php?p=10899869#p10899869
    * [https://bugzilla.mozilla.org/show_bug.cgi?id=663722 Bug 663722] - The blocklist output is including severity="0" where it shouldn't be

  • I seem to be short on space for the trial download. How can I make this work????

    I seem to have less space for my download.How can I make this download happen?????? Will I have to uninstall my old Adobe Photoshop(which has long since worked) in order for this to be installed??

    What exactly are you trying to download on what system? Feel free to download to external drives to bypass the immediate bottleneck, but that may not resolve your issue once you install....
    Mylenium

  • How can I make this shape?

    How can I make this shape in fireworks:
    I want some images in my website to have rounded corners. Im doing this by adding 4 divs with background images and absolutely positioning them, one over each corner of the image. The background images are PNGs with transparent areas. This works as the site's background is a solid color, so the rounded corners dont need to actually be transparent.
    The issue im having is that the pixels on the curve need to be semi transparent. Id love to make this shape as a vector but I dont know how.
    Thanks

    Hi,
    There is another simple way to get the shape desired. Create a rounded rectangle that is twice your corner size - both width and height wise. Now adjust the rounded corners to almost make a circle (pull the yellow corner handle towards the center of the side). Now click the corner and you will be able to toggle between the different corner types. You can now either use the shape as it is (if you need it for corners of a sprite rounded rectangle) or you can cut it up to get the desired wedge.
    - Anita

  • Just upgraded to mountain lion, when I open iphoto or photoshop, the monitor color changes.  How can I make this stop?

    For some reaon, when I launch iphoto, or any other photo program, my monitor changes to a different scheme.  How can I make this stop?  Thanks.

    try disabling it, take a took at these snaps from my phone. Might not be really clear but can give you an idea
    Hope this is clear,
    Thanks for the suppport
    Nazmul

  • I want to buy lightroom 5 as standalone product. I do not want creative cloud. How can I make this possible?

    I want to buy lightroom 5 as standalone product. I do not want creative cloud. How can I make this possible?

    Thanks YKaan,
    I do not like and do not want to pay monthly, also I do not need Photoshop just want lightroom. I want to know if I can just buy and download Lightroom or if I buy the retail package I can just have the program as standalone product.

Maybe you are looking for

  • PO message to User

    Hi MM Experts, We are able to successfully create a Message and sent to Vendor with following setting Process routies : Medium - 5 External send; Standard program i.e. SAPFM06P, FORM routine ENTRY_NEU and FORM: Custom made *However the client need a

  • Spark LabelItemRenderer Background

    I am trying to style a Spark LabelItemRenderer using only CSS without having to create a custom skin. The only thing I have not been able to do is remove the default white background for the LableItem. Docs show info for selectionColor and even alter

  • Alternative for ROW_NUMBER () OVER.

    Hi All, Is there a way to implement the below logic without using ROW_NUMBER () OVER feature that Oracle provides ? SELECT cost_object INTO out_cost_object FROM SELECT equip_no, cost_object, ROW_NUMBER () OVER (PARTITION BY equip_no, trunc(in_date) O

  • CS4 Photoshop Layers disappeared

    Hello, I somehow deleted may layers very easily. I can not see my layers anymore I am working on and searched thorough everything to bring it back. I restarted my computer and so on too. I actually didn't even save the file when it happened. I don't

  • Missing iPhoto 7.1 themes

    I have used the themes in iPhoto before but now none are listed when wanting to create a book, calendar or card. I zapped iDVD, iPhoto, iWeb and iMovie from my system and reinstalled iLife 08 from disk and still have the same problem. I do see many d