0% found this document useful (0 votes)
41 views

SQL Queries - Solution

The document contains SQL queries and views to retrieve data from a table called KudlerCOA. It includes queries to find duplicate records, records with a specific description, records over a certain balance, total balances by account, and specific records for one account. Views are then created for each query.

Uploaded by

Das Pankajashan
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views

SQL Queries - Solution

The document contains SQL queries and views to retrieve data from a table called KudlerCOA. It includes queries to find duplicate records, records with a specific description, records over a certain balance, total balances by account, and specific records for one account. Views are then created for each query.

Uploaded by

Das Pankajashan
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Note

1. Here Please change the table Name KudlerCOA to your tablename.

This view will give the list of records


SELECT Account, COUNT(*) AS numberofAccounts FROM KudlerCOA GROUP BY Account HAVING (COUNT(*) > 1) -- This view will give the list of records where short_Description='Bank Account' SELECT Account, Description, Short_Description, Balance FROM KudlerCOA WHERE (Short_Description = 'Bank Account') -- This view will give the list of records where Balance greater than 10000 SELECT Account, Description, Short_Description, Balance FROM KudlerCOA WHERE (Balance > 10000) -- This view will calculate the sum of balance of all the account SELECT Account, SUM(Balance) AS TotalBalance FROM KudlerCOA GROUP BY Account --This view will show all the details like description, short description, and balance and Totalbalance of Account = 100001 SELECT Account, SUM(Balance) AS TotalBalance, Description, Short_Description, Balance FROM KudlerCOA WHERE (Account = 100001) GROUP BY Account, Description, Short_Description, Balance

--This will display record by account=100001 Select Account,Description,Short_description,Balance from KudlerCOA Where Account=100001

SELECT Account, SUM(Balance) AS TotalBalance, Description, Short_Description, Balance FROM KudlerCOA WHERE (Account = 100001) GROUP BY Account, Description, Short_Description, Balance

SELECT Account, SUM(Balance) AS TotalBalance FROM KudlerCOA WHERE (Account = 100001) GROUP BY Account

This view will give the list of records


Create View View1 As SELECT Account, COUNT(*) AS numberofAccounts FROM KudlerCOA GROUP BY Account HAVING (COUNT(*) > 1)

-- This view will give the list of records where short_Description='Bank Account' Create View View2 As SELECT Account, Description, Short_Description, Balance FROM KudlerCOA WHERE (Short_Description = 'Bank Account')

-- This view will give the list of records where Balance greater than 10000 Create View View3 As SELECT Account, Description, Short_Description, Balance FROM KudlerCOA WHERE (Balance > 10000)

-- This view will calculate the sum of balance of all the account Create View View4 As SELECT Account, SUM(Balance) AS TotalBalance FROM KudlerCOA GROUP BY Account

--This view will show all the details like description, short description, and balance and Totalbalance of Account = 100001 Create View View5 As SELECT Account, SUM(Balance) AS TotalBalance, Description, Short_Description, Balance FROM KudlerCOA WHERE (Account = 100001) GROUP BY Account, Description, Short_Description, Balance

--This will display record by account=100001 Create View View6 As Select Account,Description,Short_description,Balance from KudlerCOA Where Account=100001

You might also like