0% found this document useful (0 votes)
31 views2 pages

SQL Queries for Account Data Analysis

The document lists various SQL queries related to the 'Account' and 'Student__c' tables, including selection, filtering, ordering, and aggregation operations. It highlights different conditions for querying data such as counting, summing, and grouping based on specific fields like 'Name', 'Industry', and 'NumberOfEmployees'. Additionally, it includes examples of using logical operators and wildcard searches in the queries.

Uploaded by

helloharry.dagar
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
31 views2 pages

SQL Queries for Account Data Analysis

The document lists various SQL queries related to the 'Account' and 'Student__c' tables, including selection, filtering, ordering, and aggregation operations. It highlights different conditions for querying data such as counting, summing, and grouping based on specific fields like 'Name', 'Industry', and 'NumberOfEmployees'. Additionally, it includes examples of using logical operators and wildcard searches in the queries.

Uploaded by

helloharry.dagar
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

QUERY ERROR

1 SELECT Name FROM Account


2 SELECT Name FROM Student__c
3 SELECT Name, NumberOfEmployees FROM Account
4 SELECT Name FROM Account WHERE Name=‘GenePoint’
5 SELECT Name, Type FROM Account WHERE Industry<>‘Energy’
6 SELECT Name, Type FROM Account WHERE Industry !=‘Energy’
7 SELECT Name, NumberOfEmployees FROM Account WHERE
NumberOfEmployees > 9000
8 SELECT Name, NumberOfEmployees FROM Account WHERE
NumberOfEmployees < 9000
9 SELECT Name, NumberOfEmployees FROM Account WHERE
NumberOfEmployees >= 9000
10 SELECT Name, NumberOfEmployees FROM Account WHERE
NumberOfEmployees <= 9000
11 SELECT Name, NumberOfEmployees FROM Account WHERE
NumberOfEmployees IN (1000,3000,9000)
12 SELECT Name FROM Account WHERE Name like ‘United%’ AND
Industry=‘Energy’
13 SELECT Name FROM Account WHERE Name like ‘Uni%’ AND
Industry=‘Energy’ OR Industry=‘Education’
14 SELECT Name FROM Account WHERE (Name like ‘Uni%’ AND
Industry=‘Energy’) OR Industry=‘Education’
15 SELECT Name FROM Account WHERE Name like ‘Uni%’ AND
(Industry=‘Energy’ OR Industry=‘Education’)
16 SELECT Name FROM Account WHERE Industry=‘Energy’ OR
Industry=‘Education’
17 SELECT Name FROM Account WHERE Industry=‘Energy’ OR
Industry=‘Education’ OR Industry=‘Electronics’
18 SELECT Name, Type FROM Account WHERE NOT Industry=‘Energy’
19 SELECT Name, Type FROM Account WHERE NOT Industry=‘Energy’
AND NOT Industry=‘Education’
20 SELECT Name, Type FROM Account WHERE (NOT Industry=‘Energy’)
AND (NOT Industry=‘Education’)
21 SELECT Name, NumberOfEmployees FROM Account ORDER BY Name
22 SELECT Name, Industry, NumberOfEmployees FROM Account ORDER
BY Industry, Name
23 SELECT Name, Industry, NumberOfEmployees FROM Account ORDER
BY Name, Industry
24 SELECT Name, Industry, NumberOfEmployees FROM Account ORDER
BY Industry, Name DESC
25 SELECT Name, Industry, NumberOfEmployees FROM Account
ORDER BY Industry, Name ASC
26 SELECT Name, Industry, NumberOfEmployees FROM Account ORDER
BY Name, Industry DESC
27 SELECT Name, NumberOfEmployees FROM Account ORDER BY Name
ASC
28 SELECT Name, NumberOfEmployees FROM Account ORDER BY Name
DESC
29 SELECT Name, Industry, NumberOfEmployees FROM Account ORDER
BY Name DESC, Industry DESC
30 SELECT Name, Industry, NumberOfEmployees FROM Account ORDER
BY Industry DESC, Name DESC
31 SELECT Name, Industry, NumberOfEmployees FROM Account ORDER
BY Industry DESC, Name
32 SELECT Name, Industry, NumberOfEmployees FROM Account ORDER
BY Industry DESC, Name ASC
33 SELECT Name, NumberOfEmployees FROM Account WHERE Name like
‘B%’
34 SELECT Name, NumberOfEmployees FROM Account WHERE Name like
‘Pyra%’
35 SELECT Name, NumberOfEmployees FROM Account WHERE Name like
‘%Ltd’
36 SELECT Name, NumberOfEmployees FROM Account WHERE Name like
‘United%Corp.’
37 SELECT Name, NumberOfEmployees FROM Account WHERE Name like
‘Gene_oint’
38 SELECT Name, NumberOfEmployees FROM Account WHERE Name like
‘G%t’
39 SELECT Name, NumberOfEmployees FROM Account WHERE Name like
‘Ge_%P%’
40 SELECT Count(Name) FROM Account
41 SELECT Sum(NumberOfEmployees) FROM Account
42 SELECT Max(NumberOfEmployees) FROM Account
43 SELECT Max(Name) FROM Account
44 SELECT Min(NumberOfEmployees) FROM Account
45 SELECT Min(Name) FROM Account
46 SELECT Avg(NumberOfEmployees) FROM Account
47 SELECT Count_Distinct(Name) FROM Account
48 SELECT Count(Name), Sum(NumberOfEmployees),
Max(NumberOfEmployees), Max(Name), Min(NumberOfEmployees),
Min(Name), Avg(NumberOfEmployees), Count_Distinct(Name) FROM
Account
49 SELECT Max(Name), NumberOfEmployees FROM Account

50 SELECT Count(Name) FROM Account GROUP BY Type


51 SELECT Count(Name), Type FROM Account GROUP BY Type
52 SELECT Count(Name), Type FROM Account GROUP BY Name

53 SELECT NumberOfEmployees, Name from Account GROUP BY


NumberOfEmployees, Name
54 SELECT NumberOfEmployees, Name from Account GROUP BY
NumberOfEmployees
55 SELECT Count(Name), Type, Industry FROM Account GROUP BY Type,
Industry
56 SELECT Count(Name), Type, Industry FROM Account GROUP BY Type

57 SELECT Count(Name), Industry FROM Account GROUP BY Industry


ORDER BY Count(Name) DESC
58 SELECT Count(Name), Type FROM Account GROUP BY Type HAVING
Count(Name)>1
59 SELECT Count(Name), Type FROM Account GROUP BY Type WHERE
Count(Name)>1
60 SELECT Count(Name), Type FROM Account GROUP BY Type HAVING
NOT Type = null
61 SELECT Count(Name), Type FROM Account GROUP BY Type HAVING
Industry = ‘Energy’

You might also like