Here you will get dense concepts of Programming...NIIT Lab At Home ; NIIT Pmr ,NIIT cycle test, Window app. Contact:rkohitkumar16@yahoo.com.
Showing posts with label SQL LAB at Home 5. Show all posts
Showing posts with label SQL LAB at Home 5. Show all posts
Sunday, 6 October 2013
02. Write a query to display the sales person ID of all the sales persons and the name of the territory to which they belong.
select salespersonID, Name
from sales.salesPerson
join sales.salesterritory
on salesperson.territoryID = salesTeriitory.TerritoryID
from sales.salesPerson
join sales.salesterritory
on salesperson.territoryID = salesTeriitory.TerritoryID
07. Write a query to display the total amount due for all the sales orders rounded off to a whole number. In addition, display the sales order ID and the type of credit card through which the payment was made.
select salesOrderID, CardType,
'Total Due'= Round(TotalDue,0)
from sales.salesOrderHeader s
join sales.CreditCard c
on s.CreditCardID= c.CreditCardID
'Total Due'= Round(TotalDue,0)
from sales.salesOrderHeader s
join sales.CreditCard c
on s.CreditCardID= c.CreditCardID
08. Write a query to display all the country region codes along with their corresponding territory IDs.
select c.CountryReglonCode, territoryID
from sales.salesTerritory s
Right Outer join sales.CountryReglonCurrecy c
on s.CountryReglonCode = c.CountryReglonCode
from sales.salesTerritory s
Right Outer join sales.CountryReglonCurrecy c
on s.CountryReglonCode = c.CountryReglonCode
10. Write a query to display the order date along with the sales order ID and the territory name. The order date should be displayed in the dd/mm/yyyy format.
select salesOrderid,Name,
Convert(Char(10),OrderDate,103)
as
'Order Date' from sales.salesOrderHerder s join sales.salesTerritory t
on t.TerritoryID= s.TerritoryID
Convert(Char(10),OrderDate,103)
as
'Order Date' from sales.salesOrderHerder s join sales.salesTerritory t
on t.TerritoryID= s.TerritoryID
11. Write a query to display the sales order ID and the territory name of the orders where the month of the order is May and the year is 2004.
select salesOrderID,Name from sales.salesOrderHeader
s join sales.salesTerritory t on s.TerritoryID =t.TerritoryID
where DateName(mm, OrderDate)= 'May'and DatePart(yy,OrderDate)=2004
s join sales.salesTerritory t on s.TerritoryID =t.TerritoryID
where DateName(mm, OrderDate)= 'May'and DatePart(yy,OrderDate)=2004
12. Write a query to display the contact ID of the customers that have the 'Vista' credit card.
select ContactID,CardType
from sales.ContactCreditCard
join sales.CreditCard no ContactCreditCardID=
CreditCard.CreditcardID
where CardType='Vista'
from sales.ContactCreditCard
join sales.CreditCard no ContactCreditCardID=
CreditCard.CreditcardID
where CardType='Vista'
13. Write a query to display the sales order IDs of the orders received from the Northeast territory.
select salesOrderID from sales.salesOrderHeader
where territoryID=(select TerritoryID
from sales.salesTerritory
Where Name='Nottheast')
where territoryID=(select TerritoryID
from sales.salesTerritory
Where Name='Nottheast')
14. Create a report containing the sales order ID of those orders where the total value is greater than the average of the total value of all the orders.
select salesOrderID, TotalDue
from sales.salesorderHeader
where totalDue > (select avg(TotalDue)
from sales.salesOrderheader)
from sales.salesorderHeader
where totalDue > (select avg(TotalDue)
from sales.salesOrderheader)
15. Write a query to display the sales order IDs of the orders that have been paid through a SuperiorCard.
select salesOrderID from sales.OrderHeader
where CreditCardID in (select CreditCardID
from sales.CreditCard Where CardType='SuperiorCard')
where CreditCardID in (select CreditCardID
from sales.CreditCard Where CardType='SuperiorCard')
16. Write a query to display the sales order ID, the order detail ID, and the total value of those orders where the total value is greater than the maximum of the total value of order ID 43662.
select salesOrderID, salesOrderDetailID,LineTotal
from sales.salesOrderDetail
where LineTotal >All (select Linetotal from sales.salesOrderDetail
Where salesOrderID=43662)
from sales.salesOrderDetail
where LineTotal >All (select Linetotal from sales.salesOrderDetail
Where salesOrderID=43662)
17. Write a query to display the details of those orders for which no discount was offered
select* from sales.salesOrderDetail
Where specialofferID=(select spcialofferID
from sales.specialoffer where type= 'No Discont')
Where specialofferID=(select spcialofferID
from sales.specialoffer where type= 'No Discont')
18. Write a query to display the sales order IDs and the credit card IDs of those cards which are expiring in the year 2007.
select salesOrderIds, CreditcardID
from sales.salesOrderHeader
where CreditCardID in (select CreditcardID
from sales.CreditCard where ExpYear=2007)
from sales.salesOrderHeader
where CreditCardID in (select CreditcardID
from sales.CreditCard where ExpYear=2007)
Subscribe to:
Posts (Atom)


