简体   繁体   中英

postgresql select different query for specific value on column

CREATE TABLE dtvs_risk_analizine_girmeme_tanimi_t
(
  id bigint NOT NULL,
  aktif boolean NOT NULL,
  price1 double precision,
  price2 double precision,
  priceoperator integer,
)
WITH (
    OIDS=FALSE
);
ALTER TABLE dtvs_risk_analizine_girmeme_tanimi_t OWNER TO postgres;

hello oll my table like on the up side. I have a price and I have many rules on the price column. I want to get all the column id value for my price value.

If priceopetaror is 0 then price1 is bigger then my price else if priceopetaror is 1 then price1 is smaller then my price else if ........

How I get all the row numbers for these rows.

If you are wanting help building an if statement in sql

SELECT if(priceopetaror = 0, 'Bigger', if(priceopetaror = 1, 'Smaller', '')) as 'Some Column Name' from dtvs_risk_analizine_girmeme_tanimi_t

at this point you have all rows and a string containing what you have specified as your desired value. You can now add a where statement to the end of your query.

where priceopetaror = 0 or priceopetaror = 1

This will ensure you only get rows that have a value of 0 or 1

If you need additional assistance please post additional criteria.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM