Code Monkey home page Code Monkey logo

postgresql's Introduction

postgresql

Task 1

Создать таблицу, выдающую следующее:

select * from users;

1 | m | Vasya | [email protected] 2 | m | Alex | [email protected] 3 | m | Alexey | [email protected] 4 | f | Helen | [email protected] 5 | f | Jenny | [email protected] 6 | f | Lora | [email protected]

create database module; create table users; create table users (id serial primary key, gender varchar(2) not null default 'm' , nane text, mail text); copy users from 'D:\Postgsql\module.txt' with delimiter '|'; select * from users;


Task 2

Получить результат вида: We have 3 boys! We have 3 girls!

ver1 select concat('We have ', count(gender), ' boys') from users where gender = 'm' union select concat('We have ', count(gender), ' girls') from users where gender = 'f';

ver2 select concat('We have ', count(gender), case when gender = 'm' then ' boys' when gender = 'f' then ' girls' else 'who are you?' end) result from users group by gender;


Task 3 Получить результат вида: This is Vasya, he has email [email protected] This is Alex, he has email [email protected] This is Alexey, he has email [email protected] This is Helen, she has email [email protected] This is Jenny, she has email [email protected] This is Lora, she has email [email protected]

ver1 select concat('This is ', name, ', he has email ', mail) from users where gender = 'm' module-# union module-# select concat('This is ', name, ', she has email ', mail) from users where gender = 'f';

ver2 select concat('This is ', name, ',', case when gender = 'm' then ' he ' when gender = 'f' then ' she ' else ' ' end, 'has email ', mail) result from users;

postgresql's People

Contributors

zhukovoleksandr avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.