Question

First issue: a) I am trying to create a SQL query so i can list all...

First issue:

a) I am trying to create a SQL query so i can list all the items that a user has bought

b)I am trying to show how much it will cost in total for user

My tables:

Table user(user_id, username, shipping_address)

Table item(item_id, item, pricing)

Table receipt(r_id, user_id, date_current)

Table rDetailing(r_id, item_id, item_in, amount_of_item)

Homework Answers

Answer #1

a) considering that your user_id attribute is of varchar type. The following is the sql query for

list all the items that a user has bought

Query:

select item_id from receipt, rdetailing where rdetailing.r_id=receipt.r_id and user_id='&user_id';

while running this query one sholuld input the user_id and query will show the list of item_id that particular user has bought.

b) how much it will cost in total for user

select sum(amount_of_item) from rdetailing where item_id in(select item_id from receipt, rdetailing where rdetailing.r_id=receipt.r_id and user_id='&user_id');

in the above query we are considering amount_of_item attribute in the rdetailing table as the pricing amount for that r_id; (Though it is not very clear from the attribute name). Otherwise the query will be different let me know in that case through coments.

or it can be:

select sum(pricing) from item where item_id in(select item_id from receipt, rdetailing where rdetailing.r_id=receipt.r_id and user_id='&user_id');

However the query will depend on what the attributes item_in and amount_of_item attributes signify in rdetailing table. If it is different from what I have assumed let me know through comments. Then the query may need modification

thank you.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Name the script for.sh.  This script will create a shopping list. Ask the user to enter items...
Name the script for.sh.  This script will create a shopping list. Ask the user to enter items separated by a space. Read the list. Use a for loop to write (use echo) the items to a file called shopping_list. You should use >> to append the output to the file, so each time the script is run the list should get longer. After the for loop finishes, display (use cat) the contents of the shopping list with 1 item per line....
I am having some trouble trying to create a linked list from a text file input...
I am having some trouble trying to create a linked list from a text file input from user The three lines respectively represent a long integer ID of a person, the name of the person, and an integer ranging from 0 to 5 indicating the threat level posed by a person. 389114 Paul Bunion 5 399012 John Doe 0 685015 Johnny Appleseed 3 179318 Tom Sawyer 2 284139 Ebenezer Scrooge 5 The full connection is: Paul Bunion -> John Doe...
Hello, I am having trouble getting my files to work together for this problem. Here is...
Hello, I am having trouble getting my files to work together for this problem. Here is the question and thank you for taking the time to answer it :) (1) Write an application that displays a menu of three items for the Jivin’ Java Coffee Shop as follows: American 1.99 Expresso 2.50 Latte 2.15 Prompt the user to choose an item using the number (1, 2, or 3) that corresponds to the item, or to enter 0 to quit the...
So, I am trying to perform a goodness of fit test on a set of data....
So, I am trying to perform a goodness of fit test on a set of data. The data consists of one thousand samples with values that range between 3.9 to 15.5. In the problem it is stated that this data could have either a gamma or normal distribution and I am meant to figure out which of these distributions it is closer to due to the results of two goodness of fit tests (one assuming gamma distribution and the other...
Binary Search Tree with multiple structs? Hi, I am having an issue with trying to create...
Binary Search Tree with multiple structs? Hi, I am having an issue with trying to create a binary search tree while having multiple structs. The struct code provided is provided for us. #define CAT_NAME_LEN 25 #define APP_NAME_LEN 50 #define VERSION_LEN 10 #define UNIT_SIZE 3 struct app_info{ char category[CAT_NAME_LEN]; // name of category char app_name[APP_NAME_LEN]; // name of application char version[VERSION_LEN]; // version number float size; // size of application char units[UNIT_SIZE]; // GB or MB float price; // price in...
I am trying to solve the following C++ problem over structures. I am having trouble with...
I am trying to solve the following C++ problem over structures. I am having trouble with the very last structure and I made a comment next to where I am confused. I included the assignment instructions and my current code. I would appreciate if anyone can help me explain what I need to do for the last structure. Thank you. Assignment Instructions Create a program that will prompt me for each of the following items: 1. Date of Birth 2....
Save your select statements as a script. Place the semicolon at the end of each SQL...
Save your select statements as a script. Place the semicolon at the end of each SQL statement. Please number your select statements from 1 to 8 in your script and comment out each number. Include your name and student number as a comment at the top of your script. The name of the script has to be Assignment1_JohnSmith. Instead of JohnSmith use your First Name and Last Name. Upload your script trough Blackboard. Use SQL Developer to create the My...
C Programming: I am working on the problem below and have got all of the code...
C Programming: I am working on the problem below and have got all of the code down, except for one part I can't figure out. The logic for the calculation where the the total at each shop is giving after each iteration of the loop. this is the formula I've got: ingredientPrice += ingredient1; It calculates the total for the first shop properly, but for the shops that follow it gives a cumulative total rather than the singular total for...
I am trying to make a program in C# and was wondering how it could be...
I am trying to make a program in C# and was wondering how it could be done based on the given instructions. Here is the code that i have so far... namespace Conversions { partial class Form1 { /// <summary> /// Required designer variable. /// </summary> private System.ComponentModel.IContainer components = null; /// <summary> /// Clean up any resources being used. /// </summary> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> protected override void Dispose(bool disposing) { if...
Question: can I have answers with the five requirements? Golf World, Inc., issued $240,000 of 6%,...
Question: can I have answers with the five requirements? Golf World, Inc., issued $240,000 of 6%, 15-year bonds dated January 1, 2018 that will pay interest semiannually on June 30 and December 31. These bonds were issued at $198,494, and the market rate of interest was 8% at the issue date. Notice that you are given the face value and the selling price, so you can already determine if it was sold at a Discount or a Premium. This problem...