TAILIEUCHUNG - SQL Puzzles & Answers- P6

Tham khảo tài liệu 'sql puzzles & answers- p6', 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ả | 182 PUZZLE 44 PAIRS OF STYLES R Answer 3 But the best way is to update the database itself and make i tem_a the smallest of the two code numbers before doing the query so this is not an issue UPDATE SalesSlips SET item_a item_b item_b item_a WHERE item_a item_b You could also do this with a TRIGGER on insertion but that would mean writing proprietary procedural code. The real answer is to mop the floor these updates and then to fix the leak with a CHECK constraint CREATE TABLE SalesSlips item_a INTEGER NOT NULL item_b INTEGER NOT NULL PRIMARY KEY item_a item_b CHECK item_a item_b pair_tally INTEGER NOT NULL Please purchase PDF Split-Merge on to remove this watermark. PUZZLE 45 PEPPERONI PIZZA 183 PUZZLE PEPPERONI PIZZA A good classic accounting problem is to print an aging report of old billings. Let s use the Friends of Pepperoni who have a charge card at 0 our pizza joint. It would be nice to find out if you should have let club members charge pizza on their cards. You have a table of charges that contains a member identification number cust_id a date bill_date and an amount pizza_amt . None of these is a key so there can be multiple entries for a customer with various dates and amounts. This is an old-fashioned journal file done as an SQL table. What you are trying to do is get a sum of amounts paid by each member within an age range. The ranges are 0 to 30 days old 31 to 60 days old 61 to 90 days old and everything over 90 days old. This is called an aging report on account receivables and you use it to see what the Friends of Pepperoni program is doing to you. Answer 1 You can write a query for each age range with UNION ALL operators like this SELECT cust_id 0-30 days AS age SUM pizza_amt FROM Friends Of Pepperoni WHERE bill_date BETWEEN CURRENT_DATE AND CURRENT_DATE - INTERVAL 30 DAY GROUP BY cust_id UNION ALL SELECT cust_id 31-60 days AS age SUM pizza_amt FROM FriendsOfPepperoni WHERE bill_date BETWEEN CURRENT_DATE - INTERVAL 31 DAY AND .

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.