-- name: CreateQualityAttribute :one
INSERT INTO qualityattributes (
      description,    
      qcp1,
      qcp2,
      qcp3,
      qcp4,
      qcp5,
      receptionform
 ) VALUES (
     $1,
     $2,
     $3,
     $4,
     $5,
     $6,
     $7
 ) RETURNING *;

-- name: GetQualityAttribute :one
SELECT * FROM qualityattributes
WHERE id = $1 LIMIT 1;

-- name: UpdateQualityAttribute :one
UPDATE qualityattributes
  set 
   description = $2,    
   qcp1 = $3,
   qcp2 = $4,
   qcp3 = $5,
   qcp4 = $6,
   qcp5 = $7,
   receptionform = $8
WHERE id = $1
RETURNING *;

-- name: DeleteQualityAttribute :exec
DELETE FROM qualityattributes WHERE id= $1;

-- name: ListQualityAttributes :many
SELECT * FROM qualityattributes;

-- name: TotalQualityAttributes :one
SELECT SUM(id) FROM qualityattributes;

-- name: ListReceptionQualityAttributes :many
SELECT * FROM qualityattributes
WHERE receptionform = true;

-- name: ListQCP1QualityAttributes :many
SELECT * FROM qualityattributes
WHERE qcp1 = true;

-- name: ListQCP2QualityAttributes :many
SELECT * FROM qualityattributes
WHERE qcp2 = true;

-- name: ListQCP3QualityAttributes :many
SELECT * FROM qualityattributes
WHERE qcp3 = true;

-- name: ListQCP4QualityAttributes :many
SELECT * FROM qualityattributes
WHERE qcp4 = true;

-- name: ListQCP5QualityAttributes :many
SELECT * FROM qualityattributes
WHERE qcp5 = true;

