Page 1 of 5 1234 ... LastLast
Results 1 to 10 of 46

Thread: SQL Quiz!

  1. #1

    Default SQL Quiz!


    Lingaw lingaw lang fellow progs and devs. this topic is about SQL scripting. everyone is welcome to answer and post on the query. once the question has been answered, anyone can post their contribution only SQL. enjoy!

  2. #2

    Default Re: SQL Quiz!

    For the introductory question.

    EMP_ID FNAME LNAME DEPT SALARY

    101 TOM CRUISE IT 15000
    107 STEVEN PAWIKS FIN 13000
    108 MARIE BISCUIT HR 12000
    102 MARK BAUTISTA OPRN 20000
    103 JOHN LAPUZ IT 11000
    105 LANI MISALUCH HR 9000
    104 OGGIE DAPOGIE FIN 9500

    Considering the table structure and records shown above,
    What is the SQL statement in order to produce the result below

    DEPT SALARY

    IT 26000

    LEVEL: Easy



  3. #3

    Default Re: SQL Quiz!

    SELECT dept, SUM(salary) AS Expr1
    FROM table1
    WHERE (dept = 'IT')
    GROUP BY dept


  4. #4

    Default Re: SQL Quiz!

    Quote Originally Posted by kyle_nexus
    SELECT dept, SUM(salary) AS Expr1
    FROM table1
    WHERE (dept = 'IT')
    GROUP BY dept

    nice kyle! cge pardz share sab


  5. #5

    Default Re: SQL Quiz!

    sakto diay? hehehe

    nagtuon pa sab ko bai, taghap ra gani to ako-a.

    kaw lang sa ask, kay ikaw man ang quiz master!

  6. #6

    Default Re: SQL Quiz!

    SQL Quiz 2:

    PROD_IDÂ* Â*ITEMÂ* Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* Â* Â*UNIT_PRICEÂ* Â* Â* Â* Â* STOCK_QTYÂ* Â* Â*

    60801Â* Â* Â* Â*CHEEZE BURGERÂ* Â* Â* Â*20.25Â* Â* Â* Â* Â* Â*30
    78000Â* Â* Â* Â*SPAGHETTIÂ* Â* Â* Â* Â* Â* Â* Â* 30.00Â* Â* Â* Â* Â* Â* Â*5
    98451Â* Â* Â* Â*BURGER STEAKÂ* Â* Â* Â* Â* 35.00Â* Â* Â* Â* Â* Â* 15
    35990Â* Â* Â* Â*DIET COKEÂ* Â* Â* Â* Â* Â* Â* Â* 18.00Â* Â* Â* Â* Â* Â* 50

    Question: Create a SQL statement to query the product having the highest price.
    Level: Easy

    Â*

  7. #7

    Default Re: SQL Quiz!

    SQL Quiz 3:

    EMP_ID FNAME LNAME DEPT SALARY

    101 TOM CRUISE IT 15000
    107 STEVEN PAWIKS FIN 13000
    108 MARIE BISCUIT HR 12000
    102 MARK BAUTISTA OPRN 20000
    103 JOHN LAPUZ IT 11000
    105 LANI MISALUCH HR 9000
    104 OGGIE DAPOGIE FIN 9500

    Question: Create a SQL statement to list all employees having a letter "O" in their first name.
    Level: Easy


  8. #8

    Default Re: SQL Quiz!

    number2:
    select top 1 * from products order by unit_price desc

    number3:
    select * from employees where fname like '%O%'

    kapoy himo quiz noh? heehee

  9. #9

    Default Re: SQL Quiz!

    Table name: Customer

    CUSTOMER_CODE CUSTOMER_NAME
    c1maldito
    c2guapito
    c3otis
    c4kyle
    c5nexus


    Table name: Product

    PRODUCT_CODE PRODUCT_NAME SELLING_PRICE
    p1tv5
    p2car10
    p3bike15
    p4house20


    Table name: Orders_H

    RECORD_NO CUSTOMER_CODE TRANSACTION_DATE
    1c101012005
    2c201022005
    3c302032005
    4c402052005
    5c402062005
    6c502252005


    Table name: Orders_D

    RECORD_NO PRODUCT_CODE SELLING_PRICE
    1p15
    1p315
    1p420
    2p420
    2p15
    3p210
    4p315
    4p420
    4p210
    5p15
    5p210
    5p315
    6p420
    6p15
    6p210
    6p315
    6p35


    say.. I wanna get info on
    sales per month per customer

    example result:

    MOTH CUSTOMER TOTAL PURCHASES
    01otis1000
    01kyle2000
    02otis2000
    02maldito1000


  10. #10

    Default Re: SQL Quiz!

    Quote Originally Posted by otis
    number2:
    select top 1 * from products order by unit_price desc

    number3:
    select * from employees where fname like '%O%'

    kapoy himo quiz noh? heehee
    Your answers for both question are ok.
    Aside from using the Top N query another way is using a PSEUDOCOLUMN asign a sequential value
    and a subquery

    SELECT rownum AS RANK,
    item, unit_price, stock_qty
    FROM (SELECT item, unit_price, stock_qty
    FROM table1 ORDER BY unit_price DESC)
    WHERE rownum = 1;

    you can manipulate the number of Top rows by changing the expression in the WHERE clause.


  11.    Advertisement

Page 1 of 5 1234 ... LastLast

Similar Threads

 
  1. o0 World's Easiest Quiz 0o
    By digital_pimpette in forum General Discussions
    Replies: 45
    Last Post: 12-02-2012, 07:47 PM
  2. SQL 101
    By BadDudes in forum Programming
    Replies: 44
    Last Post: 08-31-2012, 07:34 AM
  3. Tabangi ko plssss....PL/SQL Tuning Tips
    By zengatsu in forum Programming
    Replies: 13
    Last Post: 06-29-2006, 08:20 PM
  4. wat's d best sql back-end?
    By edshark in forum Software & Games (Old)
    Replies: 5
    Last Post: 09-15-2005, 04:41 PM
  5. HOW TO CONNECT SQL SERVER USING SQL AUTHENTICATION
    By edshark in forum Software & Games (Old)
    Replies: 13
    Last Post: 09-02-2005, 04:53 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
about us
We are the first Cebu Online Media.

iSTORYA.NET is Cebu's Biggest, Southern Philippines' Most Active, and the Philippines' Strongest Online Community!
follow us
#top