0% found this document useful (0 votes)
7 views4 pages

R Pro

Uploaded by

Shiva Teja
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)
7 views4 pages

R Pro

Uploaded by

Shiva Teja
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

SELECT DISTINCT NAME

FROM EMPLOYEE
WHERE (NAME, PHONE, AGE) IN (
SELECT NAME, PHONE, AGE
FROM EMPLOYEE
GROUP BY NAME, PHONE, AGE
HAVING COUNT(*) > 1
);
----------------------------------------------------------------------
SELECT [Link],
TRUNCATE(SUM([Link]), 2) AS total_report_amount
FROM accounts a
JOIN reports r ON [Link] = r.account_id
WHERE SUBSTR([Link], 1, 4) = '2023'
GROUP BY [Link]
ORDER BY [Link];
----------------------------------------------------------------------
SELECT [Link] AS product_name, COUNT(r.product_id) AS
total_requests
FROM products p
JOIN requests r ON [Link] = r.product_id
WHERE p.is_available = 1
GROUP BY [Link]
ORDER BY total_requests DESC, product_name ASC;
----------------------------------------------------------------------
SELECT
[Link],
COUNT([Link]) AS transaction_count,
ROUND(SUM([Link]),2) AS total_transaction_sum
FROM
accounts a
JOIN
transactions t ON [Link] = t.account_id
WHERE
t.transactions_date >= '2022-09-01'
AND t.transactions_date <= '2022-09-30'
GROUP BY
[Link]
ORDER BY
total_transaction_sum DESC;
--------------------------------------------------------------------
SELECT
[Link] AS lot_name,
COUNT([Link]) AS number_of_offers,
MIN([Link]) AS min_offer,
MAX([Link]) AS max_offer,
AVG([Link]) AS avg_offer
FROM
lots l
JOIN
amounts a ON [Link] = [Link]
GROUP BY
[Link];
----------------------------------------------------------------------
SELECT *,
CASE WHEN red = green AND green = blue THEN 'GOOD'
WHEN red = green OR green = blue OR red = blue THEN
'WORSE'
ELSE 'BAD'
END AS Result
FROM collections;
----------------------------------------------------------------------
SELECT CONCAT(p.first_name, ' ', p.last_name) AS full_name,
[Link],
SUM(CASE WHEN [Link] = 1 THEN 1 ELSE 0 END) AS
total_approvals,
SUM(CASE WHEN [Link] = 0 THEN 1 ELSE 0 END) AS
not_approved,
COUNT([Link]) AS total_requests
FROM profile AS p
LEFT JOIN relation AS r ON r.profile_id = [Link]
GROUP BY p.first_name, p.last_name, [Link];
----------------------------------------------------------------------
SELECT [Link] from COMPANY c join SALARY s on [Link]=s.
COMPANY ID GROUP by [Link] having avg([Link])>40000;
----------------------------------------------------------------------

Select

[Link] as campaign_name,

count(e.campaign_id) as total_engagements,

sum([Link]+[Link]) as total_views_and_clicks

from campaigns c

join

engagements e on [Link]=e.campaign_id

where

c.is_active=1

group by

[Link]

order by

[Link] asc;

You might also like