Question 1:can Your use a batch SQL or store procedure to calculating the number of days in a Month
Answer 1: Find the number of days of the month
Select DatePart Dd,dateadd (Dd,-1,dateadd (Mm,1,cast (getdate () as varchar) + '-' +cast (Month (GETDATE ()) as varchar) + ' -01 ' as DateTime))
Question2:can a SQL statement to calculating it!
How can I print ' to ' for books, ' sell for between $ and $, ' unknown ' for books whose The price is null, and ' other "For all other prices?"
Answer 2:
Select Bookid,bookname,price=case is null then ' unknown '
When price between the ' then ' else price end
From books
Question3:can a SQL statement to finding duplicate values!
How can I find authors and the same last name?
You can use the table authors in datatabase pubs. I want to get the result as below:
Output:
au_lname number_dups
---------------------------------------- -----------
Ringer 2
(1 row (s) affected)
Answer 3
Select Au_lname,number_dups=count (1) from authors GROUP by au_lname
Question4:can you create a cross-tab on my SQL server!
How can I get the "the" "the" the "the" the "the" about sale quality for each store and each quarter and the total sale quality to each quarter at Year 1993?
You can use the table, sales and stores in datatabase pubs.
Table Sales Record all sale detail the item for each store. Column store_id is the ID of each store, ord_date be 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
---------------------------------------- ----------- ----------- ----------- ----------- -----------
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