How do I return two aliases from the same table query? How would I do something like this:

SELECT * 
from notifications 
WHERE read=false AS unread_notifications
  and WHERE read=true 
  AND deleted=false AS read_notifications;


Result Example:

unread_notifications : [
  { id: ...,
    read: false,
    deleted: false,
    subscriber: ...,
    messageDate: ...,
    message: ...
  },
  ...etc  
];

read_notifications : [
  { id: ...,
    read: true,
    deleted: false,
    subscriber: ...,
    messageDate: ...,
    message: ...
  },
  ...etc  
];


In other words, I want to combine two queries into one:

SELECT * FROM notifications WHERE read=false LIMIT 99;
SELECT * FROM notifications WHERE read=true AND deleted=false LIMIT 99;


Example:

CREATE TABLE notifications (
  id VARCHAR(36) DEFAULT uuid_generate_v1mc(),
  read BOOLEAN DEFAULT false,
  deleted BOOLEAN DEFAULT false,
  subscriber VARCHAR NOT NULL,
  messageDate TEXT DEFAULT TO_CHAR(NOW(), 'Mon DD, YYYY HH24:MI:SS'),
  message TEXT
);

INSERT INTO notifications (subscriber, message, read)
  VALUES
  ('Sherry Waters', 'has been added to the Carlotta Corp gateway.', false),
  ('Carl Sagan', 'has cancelled his membership to the Carlotta Prime plan.', false),
  ('Parker Posey', 'is late to pay for the Carlotta Prime plan.', false),
  ('Bob Aronssen', 'has been succesfully charged for the Carlotta Prime membership!', false),
  ('Axle Root', 'has been suspended due to non-payment', true),
  ('Shaniqua Smith', 'has been succesfully charged for the Carlotta Primer membership!', true),
  ('Adam Vicks', 'has parked his membership and is now an inactive subscriber', true);
This query will return both queries as a single result. The last column added QueryIndicator is there to indicate which query the results came from. Note that UNION ALL allows duplicates, use UNION if you need to filter them out.

(SELECT
    id
    ,key
    ,READ
    ,deleted
    ,subscriber
    ,messageDate
    ,message
    ,'Unread' AS QueryIndicator
FROM notifications
WHERE READ = false LIMIT 99)

UNION ALL

SELECT
    id
    ,key
    ,READ
    ,deleted
    ,subscriber
    ,messageDate
    ,message
    ,'Read' AS QueryIndicator
FROM notifications
WHERE READ = true
    AND deleted = false LIMIT 99;


Here would be a JSON export example. Based on code found by Jack Christensen on hashrocket.

DB Fiddle Results and Example

select row_to_json(t)
from (
  select (
      select array_to_json(array_agg(row_to_json(d)))
      from (
SELECT
    id
    ,key
    ,READ
    ,deleted
    ,subscriber
    ,messageDate
    ,message
FROM notifications 
WHERE READ = true 
    AND deleted = false LIMIT 99
     ) d
    ) as Read_Notifications
    FROM notifications
WHERE READ = true
    AND deleted = false LIMIT 1)t
    union all
    select row_to_json(t)
from (
  select (
      select array_to_json(array_agg(row_to_json(c)))
      from (
SELECT
    id
    ,key
    ,READ
    ,deleted
    ,subscriber
    ,messageDate
    ,message
FROM notifications 
WHERE READ = false   LIMIT 99
     ) c
    ) as Unread_Notifications
    FROM notifications
WHERE READ = false
 LIMIT 1)t;