SQL Recipes
A FREE cookbook for SQL queries and examples
FAQ Search Today's Posts Mark Forums Read

SQL - Questions and Answers Have a SQL question? Post it here. First do a search to see if someone hasn't already answered it.

Go Back   SQL Recipes a FREE cookbook of SQL queries and examples > SQL queries and examples > SQL - Questions and Answers

Reply
 
LinkBack Thread Tools Search this Thread
  #1 (permalink)  
Old 06-25-2009, 01:49 PM
jayyu_l jayyu_l is offline
Junior Member
 
Join Date: Jun 2009
Posts: 1
jayyu_l is on a distinguished road
Question ANY dialect question:

need a SQL query


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

Last edited by jayyu_l : 06-25-2009 at 01:53 PM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote

ANSWER(S):

  #2 (permalink)  
Old 06-25-2009, 01:58 PM
jfuda jfuda is offline
Junior Member
 
Join Date: Jun 2009
Posts: 4
jfuda is on a distinguished road
Default ANY answer. Re: need a SQL query

select sno, count(*)
from your_table
group by sno ;
__________________
Joe Fuda
SQL Snippets
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3 (permalink)  
Old 07-09-2009, 09:52 AM
my_s_e_l_f my_s_e_l_f is offline
Junior Member
 
Join Date: Jul 2009
Posts: 9
my_s_e_l_f is on a distinguished road
Default ANY answer. Re: need a SQL query

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
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4 (permalink)  
Old 07-18-2009, 08:18 AM
anil anil is offline
Junior Member
 
Join Date: Jul 2009
Posts: 2
anil is on a distinguished road
Default ANY answer. Re: need a SQL query

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

Last edited by anil : 08-01-2009 at 05:32 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5 (permalink)  
Old 07-19-2009, 02:42 PM
my_s_e_l_f my_s_e_l_f is offline
Junior Member
 
Join Date: Jul 2009
Posts: 9
my_s_e_l_f is on a distinguished road
Default ANY answer. Re: need a SQL query

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?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6 (permalink)  
Old 08-09-2009, 08:58 AM
anil anil is offline
Junior Member
 
Join Date: Jul 2009
Posts: 2
anil is on a distinguished road
Default ANY answer. Re: need a SQL query

Quote:
Originally Posted by my_s_e_l_f View Post
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?


sir,
i have made myself more clear kindly help me out
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 11:20 PM.


Powered by vBulletin® Version 3.6.5
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0
Copyright (c) 2006-2008 SQL Recipes

1 2 3 4 5 6 7 8