Results 1 to 2 of 2

Thread: SQL question

  1. #1
    Join Date
    Jan 2012
    Posts
    1

    Question Unanswered: SQL question

    Hello i study now database and i have a assignment : i have a table:
    CREATE TABLE employees(
    ID INTEGER NOT NULL,
    FirstName VARCHAR (25) NOT NULL,
    SecondName VARCHAR (25) NOT NULL,
    CNMU VARCHAR (13) NOT NULL,
    Adres VARCHAR (25) NOT NULL,
    Home VARCHAR (25) NOT NULL,
    DateOfBirth DATE,
    PlaceOfBirght VARCHAR (50),
    NrTelefon VARCHAR (20),
    TrainingSchool VARCHAR (20),
    CivilStatus VARCHAR (20),
    Sex VARCHAR (10),
    SalarMax NUMERIC (10),
    SalarMediu NUMERIC (10));


    Write the SQL query that will presents CivilStatus at least 4 employees.



    i right:

    select* from test. employees where civilstatus='married' or civilstatus ='notmarried' or civilstatus ='divorced' or civilstatus ='widow' group by civilstatus;

    byt the answere was:
    Unfortunately exercise is incorrect. Exercise can be achieved by grouping and aggregate function.

    can you halp me how it should be????????
    i tray : select id,firstname,civilstatus from test.employees group by civilstatus ;

    and give me at lists 4 employees byt how can i coose to show me al the employees which are with civillstatus married??????(i have in my table 5 of them).i thinc it should be enought.
    thank you very much.

  2. #2
    Join Date
    Apr 2005
    Posts
    29
    Here is one way ..

    PHP Code:
    'select * from employees where CivilStatus = "married" order by SecondName limit 4;'
    Web Database Software - Build your own php mysql database.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •