Browse Source

up to example query 35

Jared Dunbar 2 years ago
parent
commit
950a888961
Signed by: Jared Dunbar <jrddunbr@gmail.com> GPG Key ID: CF202CC859BAC692
1 changed files with 99 additions and 0 deletions
  1. 99
    0
      ZAGI.sql

+ 99
- 0
ZAGI.sql View File

@@ -279,10 +279,108 @@ WHERE productprice >= 50
279 279
 GROUP BY vendorid, categoryid
280 280
 HAVING COUNT(*) > 1;
281 281
 
282
+-- 24
282 283
 
284
+SELECT productid, SUM(noofitems)
285
+FROM soldvia
286
+GROUP BY productid;
287
+HAVING SUM(noofitems) > 3;
288
+
289
+-- 25
290
+
291
+SELECT productid, COUNT(tid)
292
+FROM soldvia
293
+GROUP BY productid
294
+HAVING COUNT(tid) > 1;
295
+
296
+-- 26
297
+
298
+SELECT productid
299
+FROM soldvia
300
+GROUP BY productid
301
+HAVING SUM(noofitems) > 3;
302
+
303
+-- 27
304
+
305
+SELECT productid
306
+FROM soldvia
307
+GROUP BY productid
308
+HAVING COUNT(tid) > 1;
309
+
310
+-- 28
311
+
312
+SELECT productid, productname, productprice
313
+FROM product
314
+WHERE productprice < (
315
+  SELECT AVG(productprice)
316
+  FROM product
317
+);
318
+
319
+-- 29
320
+
321
+SELECT productid, productname, productprice
322
+FROM product
323
+WHERE productid IN (
324
+  SELECT productid
325
+  FROM soldvia
326
+  GROUP BY productid
327
+  HAVING SUM(noofitems) > 3
328
+);
329
+
330
+-- 30
331
+
332
+SELECT productid, productname, productprice
333
+FROM productd
334
+WHERE productid IN (
335
+  SELECT productid
336
+  FROM soldvia
337
+  GROUP BY productid
338
+  HAVING COUNT(tid) > 1
339
+);
340
+
341
+-- 31
342
+
343
+SELECT productid, productname, vendorname, productprice
344
+FROM product, vendor
345
+WHERE product.vendorid = vendorid;
346
+
347
+-- 31a
348
+
349
+SELECT p.productid, p.productname, v.vendorname, p.productprice
350
+FROM product p, vendor v
351
+WHERE p.vendorid = v.vendorid
283 352
 
353
+-- 31b
284 354
 
355
+SELECT p.productid pid, p.productname pname, v.vendorname vname, p.productprice pprice
356
+FROM product p, vendor v
357
+WHERE p.vendorid = v.vendorid;
285 358
 
359
+-- 31c
360
+
361
+SELECT p.productid AS pid, p.productname AS pname, v.vendorname AS vname, p.productprice AS pprice
362
+FROM product p, vendor v
363
+WHERE p.vendorid = v.vendorid;
364
+
365
+-- 32
366
+
367
+SELECT productid, productname, vendorname, productprice
368
+FROM product, vendor
369
+
370
+-- 33
371
+
372
+SELECT *
373
+FROM product, vendor;
374
+
375
+-- 34
376
+
377
+SELECT *
378
+FROM product, vendor
379
+WHERE product.vendorid = vendor.vendorid;
286 380
 
381
+-- 35
287 382
 
383
+SELECT t.tid, t.tdate, p.productname, sv.noofitems AS quantity, (sv.noofitems * p.productprice) AS amount
384
+FROM product p, salestransaction t, soldvia sv
385
+WHERE sv.productid = p.productid AND sv.tid = t.tid
386
+ORDER BY t.tid;

Loading…
Cancel
Save