ÉèΪÊ×Ò³ ¼ÓÈëÊÕ²Ø

TOP

oracleÃæÊÔÌâ¼°Æä´ð°¸(¾Å)
2014-11-24 02:23:02 ¡¾´ó ÖРС¡¿ ä¯ÀÀ:2715´Î
Tags£ºoracle ÊÔÌâ ¼°Æä ´ð°¸
L Server!
How can I get the report about sale quality for each store and each quarter and the total sale quality for each quarter at year 1993
You can use the table sales and stores in datatabase pubs.
Table Sales record all sale detail item for each store. Column store_id is the id of each store, ord_date is the order date of each sale item, and column qty is the sale qulity. Table stores record all store information.
I want to get the result look like as below:
Output:
stor_name Total Qtr1 Qtr2 Qtr3 Qtr4
¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª- ¡ª¡ª¡ª¨C ¡ª¡ª¡ª¨C ¡ª¡ª¡ª¨C ¡ª¡ª¡ª¨C ¡ª¡ª¡ª¨C
Barnum¡¯s 50 0 50 0 0
Bookbeat 55 25 30 0 0
Doc-U-Mat: Quality Laundry and Books 85 0 85 0 0
Fricative Bookshop 60 35 0 0 25
Total 250 60 165 0 25


Answer 4£ºÓö¯Ì¬SQLʵÏÖ
23. Question5: The Fastest Way to Recompile All Stored Procedures
I have a problem with a database running in SQL Server 6.5 (Service Pack 4). We moved the database (object transfer) from one machine to another last night, and an error (specific to a stored procedure) is cropping up. However, I can¡¯t tell which procedure is causing it. Permissions are granted in all of our stored procedures; is there a way from the isql utility to force all stored procedures to recompile
Tips: sp_recompile can recomplie a store procedure each time
Answer 5£ºÔÚÖ´Ðд洢¹ý³Ìʱ,ʹÓà with recompile Ñ¡ÏîÇ¿ÖƱàÒëеļƻ®£»Ê¹ÓÃsp_recompileϵͳ´æ´¢¹ý³ÌÇ¿ÖÆÔÚÏ´ÎÔËÐÐʱ½øÐÐÖØбàÒë
24. Question6: How can I add row numbers to my result set
In database pubs, have a table titles , now I want the result shown as below,each row have a row number, how can you do that
Result:
line-no title_id
¡ª¡ª¡ª¨C ¡ª¡ª¨C
1 BU1032
2 BU1111
3 BU2075
4 BU7832
5 MC2222
6 MC3021
7 MC3026
8 PC1035
9 PC8888
10 PC9999
11 PS1372
12 PS2091
13 PS2106
14 PS3333
15 PS7777
16 TC3218
17 TC4203
18 TC7777
Answer 6£º
¨CSQL 2005µÄд·¨
select row_number() as line_no ,title_id from titles
¨CSQL 2000µÄд·¨
select line_no identity(int,1,1),title_id into #t from titles
select * from #t
drop table #t
25. Question 7: Can you tell me what the difference of two SQL statements at performance of execution


Statement 1:
if NOT EXISTS ( select * from publishers where state = ¡®NY¡¯)
begin
SELECT ¡®Sales force needs to penetrate New York market¡¯
end
else
begin
SELECT ¡®We have publishers in New York¡¯
end
Statement 2:
if EXISTS ( select * from publishers where state = ¡®NY¡¯)
begin
SELECT ¡®We have publishers in New York¡¯
end
else
begin
SELECT ¡®Sales force needs to penetrate New York market¡¯
end
Answer 7£º²»Í¬µã:Ö´ÐÐʱµÄÊÂÎñÊý,´¦Àíʱ¼ä,´Ó¿Í»§¶Ëµ½·þÎñÆ÷¶Ë´«Ë͵ÄÊý¾ÝÁ¿´óС
26. Question8: How can I list all California authors regardless of whether they have written a book
In database pubs, have a table authors and titleauthor , table authors has a column state, and titleauhtor have books each author written.
CA behalf of california in table authors.
Answer 8£º
select * from authors where state=¡¯CA¡¯
27. Question9: How can I get a list of the stores that have bought both ¡®bussiness¡¯ and ¡®mod_cook¡¯ type books
In database pubs, use three table stores,sales and titles to implement this requestment. Now I want to get the result as below:
stor_id stor_name
¡ª¡ª- ¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª¡ª-
¡­
7896 Fricative Bookshop
¡­
¡­
¡­
Answer 9£º
select distinct a.stor_id, a.stor_name from stores a,sales b,titles c
where a.stor_id=b.stor_id and b.title_id=c.title_id and c.type=¡¯business¡¯ and
exists(select 1 from sales k,titles g where stor_id=b.stor_id
and k.title_id=g.title_id and g.type=¡¯mod_cook¡¯)
28. Question10: How can I list non-contignous data
In database pubs, I create a table test using statement as below, and I insert several row as below
create table test
( id int primary key )
go
insert into test values (1 )
insert into test values (2 )
insert into tes

Ê×Ò³ ÉÏÒ»Ò³ 6 7 8 9 ÏÂÒ»Ò³ βҳ 9/9/9
¡¾´ó ÖРС¡¿¡¾´òÓ¡¡¿ ¡¾·±Ìå¡¿¡¾Í¶¸å¡¿¡¾Êղء¿ ¡¾ÍƼö¡¿¡¾¾Ù±¨¡¿¡¾ÆÀÂÛ¡¿ ¡¾¹Ø±Õ¡¿ ¡¾·µ»Ø¶¥²¿¡¿
ÉÏһƪ£ºÈçºÎÅжÏÒ»¶Î³ÌÐòÊÇÓÉ C ±àÒë³ÌÐò.. ÏÂһƪ£ºÓÃÁ´±íÄ£Äâ´óÕûÊý¼Ó·¨ÔËËã

×îÐÂÎÄÕÂ

ÈÈÃÅÎÄÕÂ

Hot ÎÄÕÂ

Python

C ÓïÑÔ

C++»ù´¡

´óÊý¾Ý»ù´¡

linux±à³Ì»ù´¡

C/C++ÃæÊÔÌâÄ¿