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

SQL Sample Questions

Uploaded by

Richie Sam
Copyright
© © All Rights Reserved
Available Formats
Download as XLSX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views

SQL Sample Questions

Uploaded by

Richie Sam
Copyright
© © All Rights Reserved
Available Formats
Download as XLSX, PDF, TXT or read online on Scribd
You are on page 1/ 7

Sample Questions

Table : Station: LinkTable : Trip LinkYou can write the query here itself for this. List of station names with more than 10

Write an SQL query to give the details(first_name, last_name, DoB and Mobile number) of all managers working by
number as XXXXX i.e. 8197712345 will become 81977XXXXX.

Data Source: https://docs.google.com/spreadsheets/d/e/2PACX-1vQ9vbsxw0kx1NgqKOTlu9DT5LEDW-mhvdNruP


kpFhsnpwgYQ72VWULdclf32/pubhtml

Follow-up Questions:

- Write a SQL query to give the total sum of incoming and outgoing call duration of all the employees.
- Write an SQL query to give me only those mobile numbers where the total outgoing call duration is greater then th
SQL::

Say we have a table `transactions` in the form:

```
| date | cash_flow |
|------------|-----------|
| 2018-01-01 | -1000 |
| 2018-01-02 | -100 |
| 2018-01-03 | 50 |
| ... | ... |
```

Where `cash_flow` is the revenues minus costs for each day.

**Task: **Write a query to get *cumulative* cash flow for each day such that we end up with a table in the form belo

```
| date | cumulative_cf |
|------------|---------------|
| 2018-01-01 | -1000 |
| 2018-01-02 | -1100 |
| 2018-01-03 | -1050 |
| ... | ... |
```

Follow-up Question:

Calculate the rolling average of the three days.


Can you introduce yourself?

You have a dataset containing 4 columns which gives insight into entire user log of instagram for a complete day. D
OUT, Customer_ID, Session_ID) 1) How many users were active at 9:00AM on the platform (yesterday)? 2) Max. u
was active from 9:00AM to 10:00AM on the platform (yesterday)?
tarted from the station)."Can you tell me the execution order of this?Follow-up Questions:Do you see any other optimal way to do it?
other optimal way to do it? Do you see any difference in inner join and left join in terms of the execution efficiency? For each region_
efficiency? For each region_id top 3 origination/start stations (by trip count).
Table : Station
id name region_id
352 Goettingen St 3
91 Berry St at Ki 3
148 Horton St at 4 13
105 16th St at Pro 3
172 College Ave at 12
188 Dover St at 57 12
514 Laurel St at Ca 3
395 Kerley Dr at 5
234 Farnam St at F 12
357 2nd St at Julia 5

Table : Trip
trip_id start_station_id start_ts
63,120,150,729,180,700 67 2015-07-29 18:07:00 UTC
38,520,141,029,054,000 73 2014-10-29 05:40:00 UTC
47,920,150,131,113,100 50 2015-01-31 11:31:00 UTC
44,220,141,020,171,300 77 2014-10-20 17:13:00 UTC
48,620,140,225,153,800 77 2014-02-25 15:38:00 UTC
12,492,018,041,718,200 59 2018-04-17 18:24:16 UTC
38,620,160,217,091,600 50 2016-02-17 09:16:00 UTC
34,820,150,410,164,400 65 2015-04-10 16:44:00 UTC
38,020,141,014,070,200 69 2014-10-14 07:02:00 UTC
9,072,017,092,916,040 4 2017-09-29 16:04:27 UTC
38,420,150,810,084,100 55 2015-08-10 08:41:00 UTC
17,920,151,111,231,400 2 2015-11-11 23:14:00 UTC
40,620,150,119,101,100 69 2015-01-19 10:11:00 UTC
37,520,151,028,091,600 69 2015-10-28 09:16:00 UTC
52,520,150,325,122,600 66 2015-03-25 12:26:00 UTC
26,982,017,121,108,100 84 2017-12-11 08:10:26 UTC
34,020,160,705,090,300 55 2016-07-05 09:03:00 UTC
9,252,017,083,119,260 163 2017-08-31 19:26:04 UTC
33,052,017,121,213,400 27 2017-12-12 13:44:51 UTC
33,782,018,022,308,300 22 2018-02-23 08:34:58 UTC
capacity has_kiosk
23 TRUE
23 TRUE
23 FALSE
19 TRUE
15 TRUE
15 FALSE
23 TRUE
27 TRUE
19 FALSE
23 TRUE

end_station_id end_ts bike_id subscriber_type


69 2015-07-29 18:15:00 UTC 631 Subscriber
77 2014-10-29 05:45:00 UTC 385 Subscriber
74 2015-01-31 17:12:00 UTC 479 Customer
66 2014-10-20 17:25:00 UTC 442 Subscriber
64 2014-02-25 15:46:00 UTC 486 Subscriber
145 2018-04-17 18:47:37 UTC 1249 Subscriber
39 2016-02-17 09:25:00 UTC 386 Subscriber
69 2015-04-10 16:47:00 UTC 348 Subscriber
62 2014-10-14 07:07:00 UTC 380 Subscriber
16 2017-09-29 16:13:59 UTC 907 Subscriber
51 2015-08-10 08:44:00 UTC 384 Subscriber
16 2015-11-11 23:25:00 UTC 179 Subscriber
65 2015-01-19 10:15:00 UTC 406 Subscriber
56 2015-10-28 09:25:00 UTC 375 Subscriber
66 2015-03-25 12:32:00 UTC 525 Customer
24 2017-12-11 08:31:18 UTC 2698 Subscriber
66 2016-07-05 09:24:00 UTC 340 Subscriber
200 2017-08-31 19:34:22 UTC 925 Subscriber
17 2017-12-12 13:50:01 UTC 3305 Subscriber
93 2018-02-23 08:46:05 UTC 3378 Subscriber

You might also like