TAILIEUCHUNG - SQL Puzzles & Answers- P4

Tham khảo tài liệu 'sql puzzles & answers- p4', công nghệ thông tin, cơ sở dữ liệu phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả | 102 PUZZLE 23 MAGAZINE INSERT INTO Sales VALUES 2 3 3 INSERT INTO Sales VALUES 3 3 3 INSERT INTO Sales VALUES 4 3 1 INSERT INTO Sales VALUES 5 3 1 INSERT INTO Sales VALUES 6 3 3 INSERT INTO Sales VALUES 7 3 3 -- stand 4 INSERT INTO Sales VALUES 1 4 1 INSERT INTO Sales VALUES 2 4 1 INSERT INTO Sales VALUES 3 4 4 INSERT INTO Sales VALUES 4 4 1 INSERT INTO Sales VALUES 5 4 1 INSERT INTO Sales VALUES 6 4 1 INSERT INTO Sales VALUES 7 4 2 SELECT stand_nbr FROM SELECT stand_nbr AVG CASE WHEN title 2667 THEN net_sold_qty END AVG CASE WHEN title 48632 THEN net_sold_qty END AVG CASE WHEN title 1107 THEN net_sold_qty END avg_1107 FROM Sales Titles WHERE GROUP BY stand_nbr AS T stand_nbr avg_2667 avg_48632 avg_1107 WHERE avg_1107 5 OR avg_2667 2 AND avg_48632 2 A minor note leaving off the ELSE NULL in a CASE expression is legal shorthand but I prefer to use it as a placeholder for future updates and additions as well as a reminder that a NULL is being created. Please purchase PDF Split-Merge on to remove this watermark. PUZZLE 24 ONE IN TEN 103 PUZZLE ONE IN TEN Alan Flancman ran into a problem with some legacy system data that had been moved over to an SQL database. The table looked like this CREATE TABLE MyTable keycol INTEGER NOT NULL fl INTEGER NOT NULL f2 INTEGER NOT NULL f3 INTEGER NOT NULL f4 INTEGER NOT NULL f5 INTEGER NOT NULL f6 INTEGER NOT NULL f7 INTEGER NOT NULL f8 INTEGER NOT NULL f9 INTEGER NOT NULL f10 INTEGER NOT NULL The columns fl through f10 were an attempt to flatten out an array into a table. What he wanted was an elegant way to test against the f1 through f10 columns to find the rows that had exactly one nonzero value in their columns. How many different approaches can you find We are looking for variety and not performance. Answer 1 You could use the SIGN function in Sybase and other SQL products. This function returns -1 0 or 1 if the argument is negative zero or positive respectively. Assuming that .

TỪ KHÓA LIÊN QUAN
TAILIEUCHUNG - Chia sẻ tài liệu không giới hạn
Địa chỉ : 444 Hoang Hoa Tham, Hanoi, Viet Nam
Website : tailieuchung.com
Email : tailieuchung20@gmail.com
Tailieuchung.com là thư viện tài liệu trực tuyến, nơi chia sẽ trao đổi hàng triệu tài liệu như luận văn đồ án, sách, giáo trình, đề thi.
Chúng tôi không chịu trách nhiệm liên quan đến các vấn đề bản quyền nội dung tài liệu được thành viên tự nguyện đăng tải lên, nếu phát hiện thấy tài liệu xấu hoặc tài liệu có bản quyền xin hãy email cho chúng tôi.
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.