1. We have moved to a new forum! There may be a few things not working properly so please let us know if you find a bug. Remember to use the bbCode [ sql ] tag for SQL statements.

need a SQL query

Discussion in 'SQL - Questions and Answers' started by jayyu_l, Jun 25, 2009.

  1. jayyu_l New Member

    Hi,

    I am using Oracle 10g, I have the following requirement:

    I want fetch the count of all position patterns with in a number pool.

    For e.g if there is a database table with SNO and status as the DB columns, the data representation is as follows:

    SNO, STATUS
    -------------------
    1, Y
    2 , Y
    -- , --
    100, Y

    assuming that the table has records from 1 to 100.

    I want to write an optimized SQL query which will list out the count of numbers starting with 1,2,3 .... 100

    Start with, Count
    -------------------
    1 , 12 (there are 12 numbers between 1 to 100 which start with 1)
    2 , 11
    -- , --
    10 , 2


    Thanks and Regards
    Jay
  2. jfuda New Member

    select sno, count(*)
    from your_table
    group by sno ;
  3. my_s_e_l_f New Member

    Select substr(sno,1,1) starts_with, count(*)
    from <table>
    group by substr(sno,1,1)


    --Did'nt run the query...you got the concept...fix if you have syntax error..

    Cheers,
    Me
  4. anil New Member

    SIR,
    i have two tables
    one is q_bank and another is blueprint
    in q_bank i have col subject question and category(A,B,C)
    in blueprint i have the no for A,B,C(01,01,02)
    now i need a query so that output should be question and category but no of rows are decided by values of A,B,C from blueprint table

    q_bank table for example -
    question subject cat
    define x x A
    define y y B
    define z x A
    define 1 y A
    define2 x B
    define n x C
    define t y C

    blueprint
    subject A B C
    X 1 0 1
    y 2 1 0

    my requirement that query should give question from q_bank and no of question should be limited by numbers of A,B,C of blueprint

    thanx
    kindly help me out
    my emailid-anil.1974@yahoo.com
  5. my_s_e_l_f New Member

    Your question did not make any sense to me so far. Please give examples so I could be clear on what and "why" you want this?
  6. anil New Member



    sir,
    i have made myself more clear kindly help me out

Share This Page