Question

In: Computer Science

Please write the SQL statement for the following. I am using the Adventurework2014 database. 1. Create...

Please write the SQL statement for the following. I am using the Adventurework2014 database.

1. Create a login for AdventureWorks employees. An employee login should be composed of the first letter of a person's first name combined with their last name. In addition, the login should be all lower case characters. All the required information is located in Person.Person table. Employees can be identified by "EM" value in the PersonType field. The output should include BusinessEntityID, first name (FirstName), last name (LastName), and EmpLogin alias for the login column. **Hint use the substring fuction which takes the following format:

- expression: is a character, binary, text, ntext, or image expression

-start is an integer of bigint expression that specifies where the returned characters start. (The numbering is 1 based, meaning that the first character in the expression is 1). if start is less than 1, the returned expression will begin at the first character that is specified in expression. In this case, the number of characters that are returned is the largest value of either the sum of start + length -1 or 0. If start is greater than the n umber of characters in the value expression, a zero length expression is returned.

-length - is a positive integer of bigint expression that specifies how many characters of the expression will be returned. If length is negative, an error is generated, and the statement is terminated. If the sum of start and length is greater than the number of characters in expression, the whole value expression beginning at start is returned.

2. From Sales.SalesOrderHeader table, list all orders (SalesOrderNumber, OrderDate) that were placed in June of 2011. Use date manipulation functions.

Please only answer if you know the correct answer. I will give a thumbs up if the answer is correct and down if incorrect.

Solutions

Expert Solution

Query 1:

Oracle:

select businessentityid,firstname,lastname,lower(substr(firstname,0,1)||lastname) as emplogin
from person
where persontype='EM';

Sql server:

select businessentityid,firstname,lastname,lower(concat(substring(firstname,1,1),lastname)) as emplogin
from person
where persontype='EM';

Output:

Query 2:

Oracle:

select salesordernumber,orderdate
from salesorderheader
where to_char(orderdate,'MM')='06'
and to_char(orderdate,'YYYY')='2011';

Sql Server:

select salesordernumber,orderdate
from salesorderheader
where datename(month,orderdate)='June'
and year(orderdate)='2011';

Output:


Related Solutions

Create the actual database using SQL syntax. This is completed using a Database Application (i.e Microsoft...
Create the actual database using SQL syntax. This is completed using a Database Application (i.e Microsoft Access, Oracle, or MySQL) as indicated by your professor. After creating the database – populate it with some data (could be made up). SQL syntax and the DB application will be discussed and taught in class. This is the final deliverable of the group project. Assignment is due by the due date as indicated by your professor. *Make sure to submit the completed database...
Write the SQL queries that accomplish the following tasks using the AP Database 9. Write a...
Write the SQL queries that accomplish the following tasks using the AP Database 9. Write a select statement to show the invoicelineitemdescriptions that have the total invoicelineitemamount >1000 and the number of accountno is >2. 10. Write a select statement that returns the vendorid, paymentsum of each vendor, and the number of invoices of each vendor, where paymentsum is the sum of the paymentotal column. Return only the top ten vendors who have been paid the most and the number...
Create the following SQL queries using the lyrics database below 1. List the first name, last...
Create the following SQL queries using the lyrics database below 1. List the first name, last name, and region of members who do not have an email. 2. List the first name, last name, and region of members who do not have an email and they either have a homephone ending with a 2 or a 3. 3. List the number of track titles that begin with the letter 's' and the average length of these tracks in seconds 4....
Using your downloaded DBMS (MS SQL Server), create a new database. Create the database tables based...
Using your downloaded DBMS (MS SQL Server), create a new database. Create the database tables based on your entities defining The attributes within each table The primary and foreign keys within each table *****Show your database tables, tables attributes, primary and foreign keys***** Do not forget to check the lesson slides and videos that show you how to convert an ER/EER into a database schema, and how to create a database and tables using MS SQL Server.
DBMS Create/Insert/Update SQL I need the create, insert, and update SQL statement for this table: Customer...
DBMS Create/Insert/Update SQL I need the create, insert, and update SQL statement for this table: Customer PK Customer ID Text Phone Number int name text address ID int email text FK vendor ID int Vendor is the name of the table the FK comes from.
Using SQL create a new database called school_app. Create a student table with fields id (auto...
Using SQL create a new database called school_app. Create a student table with fields id (auto increment), first_name, last_name. Create a course table with fields id (auto increment), course code (such as ITC or MTH), and course number (such as 100 or 295). Note that the relationship between student and course is many-to-many (n:m). Create a join table called student_course that implements the n:m relationship with fields id (auto increment), student_id, course_id, and grade (which has values 0, 1, 2,...
I am working on an assignment using SQL Server Management and I need to print an...
I am working on an assignment using SQL Server Management and I need to print an ERD to a single page as a PDF file. I am not sure how to do this especially because the diagram is rather large... I am using SQL Server Management Studio I have created an Entity relationship diagram for AdventureWorks that includes all product tables. There are many tables.How do I print it to a single page?
Please create using only For loops, as simple as possible as I am attending Java1 Create...
Please create using only For loops, as simple as possible as I am attending Java1 Create two Java programs that do the following: a. Use a for loop to print the numbers below on a single line as shown. 1 2 4 8 16 32 64 128. b. Ask the user to enter numbers using the for loop.  First ask the user how many numbers they will be entering in. Print the sum and average of the entered numbers. c. Write...
Create three MySQL database tables and write SQL scripts to read, insert, and delete data. The...
Create three MySQL database tables and write SQL scripts to read, insert, and delete data. The first database table will contain the names of at least four movies. The second table will be a list of actors who appear in the movies. The third table will be an associative table that describes the relationship between the actors and their movies (which actors appear in which movies). Actors and movies have a “many-to-many relationship,” meaning an actor can be in multiple...
Create three MySQL database tables and write SQL scripts to read, insert, and delete data. The...
Create three MySQL database tables and write SQL scripts to read, insert, and delete data. The first database table will contain the names of at least four movies. The second table will be a list of actors who appear in the movies. The third table will be an associative table that describes the relationship between the actors and their movies (which actors appear in which movies). Actors and movies have a “many-to-many relationship,” meaning an actor can be in multiple...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT