About the Databases - MySQL & Mongo-Node category

Start the conversation on Databases here - MySQL, Mongo and Node! Post your queries and doubts regarding the same!

2 Likes

Assume you have a collection called “orders” with documents containing the following fields:

  • _id: unique identifier for the order
  • customer_id: unique identifier for the customer who placed the order
  • order_date: date when the order was placed
  • order_total: total amount of the order
  • order_items: an array of objects, where each object contains the following fields:
    • item_id: unique identifier for the item
    • item_name: name of the item
    • item_price: price of the item
    • quantity: quantity of the item ordered

Write a MongoDB query to retrieve the top 5 customers with the highest total order amount, along with the number of orders they placed and the average order amount.

1.To see all the databases which command is used?

A) Show database;

B) Show databases;

C) Show database();

D) Show_all database;

2. In the following statement, what do you mean by the ‘student’?

USE student;

A) Database name

B) Row name

C) Column name

D) Table name

3.Which of the following command is used to delete a database?

A) DELETE DATABASE_NAME;

B) DROP DATABASE_NAME;

C) DROP DATABASE DATABASE_NAME;

D) DELETE DATABASE DATABASE_NAME;

4) Suppose you have a table named to test and inside this table you have a column named CGPA now if you are asked to change the column named CGPA to total percentage, using alter command then which of the following statement you will write?

A) ALTER TABLE test CHANGE COLUMN 'cgpa’ 'total_percentage’ int;

B) ALTER test table CHANGE 'cgpa’ ,'total_percentage’ int;

C) ALTER TABLE test CHANGE 'cgpa 'total_percentage’ int;

D) Answer: A) ALTER TABLE test CHANGE COLUMN 'cgpa’ 'total_percentage’ int;

5. Suppose you have two columns named student_name and student_department inside table student_details and you are asked to update the value of these two columns where ID=4 then what statement you will write?

A) UPDATE student_details SET Student_name=“ram”, Student_department=‘Chemical’ WHERE ID=‘4’;
B) UPDATE table student_details SET column_name Student_name=“ram”, Student_department=‘Chemical’ WHERE ID=‘4’;
C) UPDATE student_details SET Student_name=“ram” and Student_department=‘Chemical’ WHERE ID=‘4’;

2 Likes

Here the answers are as following:-
question1-B)Show databases;
question2-A)database name
qusetion3-C) DROP DATABASE DATABASE_NAME;
qusetion4-A) ALTER TABLE test CHANGE COLUMN ‘cgpa’ ‘total_percentage’ int;
question5-A) UPDATE student_details SET Student_name=‘ram’, Student_department=‘Chemical’ WHERE ID=‘4’;

2 Likes

1.Concatenate two columns: Write a query to concatenate two columns and display the result in a single column
2.Find the difference between two dates: Write a query to find the difference between two dates.
3.Find the average of top N records: Write a query to find the average of the top N records from a table.
4.Count the number of occurrences of a character: Write a query to count the number of occurrences of a given character in a string

4 Likes

Cant to install MYSQL (Full in setup Type).





Please check and help me to install.

Am struggling past two days.

1 Like

if your installing SQL Workbench select " Full " and proceed @sathsaran01

2 Likes

You need to install X86 and X64 as well. I have provided you the link to download it

2 Likes

Please share in here which one need.

1 Like

X64 and X86 @sathsaran01

2 Likes

Thank you mam,

Will did and update.

2 Likes

@sathsaran01
Keep practicing :slightly_smiling_face:
Keep it up :heart:

2 Likes

Hi Mam,

Now its fine to work.

Thank you :pray:

3 Likes

Cool @sathsaran01
keep practicing

2 Likes


Cant install mysql, i have reinstalled 2-3 times but same issue.

3 Likes

Hi @shindesudarshan58 , please go through this thread here, the resolution is provided here. MYSQL installation Doubt I hope this helps you! :smiley:

1 Like

@ please go through the following link and download X64 and X86 and run it.

Try this
I am hopeful that it will help :+1:

1 Like

hey everyone,
this is an interesting question i found.
Try to answer it in the comments

Also, This is a website i found where we can practice sql queries. Make use of the website. its free for most part.

Hope you folks find it useful

4 Likes
select distinct candidate_id
from candidates
where skill="python" or skill="Tableau" or skill=postgreSQL; 
1 Like

@cmsathwik44 should be and instead of or
also you didn’t sort them by id

1 Like