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...
for C++, I am trying to create a function that prints a 2D array. Can you...
for C++, I am trying to create a function that prints a 2D array. Can you instruct me on the easiest way to do so? Please do not make it complicated, we have no started learning about pointers yet, either, so it can't be done that way.
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...
So for one of my classes I am updating the game Minesweeper. So for the game...
So for one of my classes I am updating the game Minesweeper. So for the game I was wanting to change the size of the grid based on user preference. I am new to working with tkMesseageBoxs. I am trying to update the variable SIZE_X and SIZE_Y with the tkMeassage box. Size_x and Size_y control the size of the grid. For the first one I tried assigning it to the variable a and b. For the other variables I was...
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...
I posted the following JavaScript question a bit earlier. However. I made the mistake of copying...
I posted the following JavaScript question a bit earlier. However. I made the mistake of copying it twice. So when I pasted it into the question box here on CHEGG it might have been somewhat confusing to read and understand. So here it is again in a much more simple format. I am in coding school and this is the JS II set of questions. Any help would be greatly appreciated !! Basically the answers will just give me an...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT