logo
down
shadow

Increase price by percentage, results rounded


Increase price by percentage, results rounded

Content Index :

Increase price by percentage, results rounded
Tag : sql , By : Thomas Gueze
Date : November 25 2020, 01:01 AM

With these it helps Use ROUND():
UPDATE my_table
    SET price = ROUND(price * 1.4, 0);

Comments
No Comments Right Now !

Boards Message :
You Must Login Or Sign Up to Add Your Comments .

Share : facebook icon twitter icon

How to increase price with percentage?


Tag : sql , By : Laques
Date : October 23 2020, 03:00 PM
this will help For example
SELECT product_c, price, (price* 1.20) as new_price FROM Table;

Elegant Way to Increase Price by Percentage with PHP


Tag : php , By : iyogee
Date : March 29 2020, 07:55 AM
I wish this helpful for you This should work on every case
$price = $price + ($percentage / 100 ) * $price

Microsoft SQL Server, increasing price by percentage, rounded up


Tag : sql , By : Ronnie Carlin
Date : March 29 2020, 07:55 AM
may help you . This is what I understood, I'm surprised the question got interpreted this many ways:
BEGIN TRAN

UPDATE products_tbl
SET price = CEILING(price * 1.03)

SELECT *
FROM products_tbl

ROLLBACK TRAN -- Because we only answer w/ commits for a fee.

Displaying price only when the variation is selected and discount in percentage relatively to the regular price


Tag : php , By : Trevor Cortez
Date : March 29 2020, 07:55 AM
hop of those help? After some search, there this simple dedicated filter hook woocommerce_show_variation_price that will make exactly what you are expecting:
add_filter( 'woocommerce_show_variation_price', 'filter_show_variation_price', 10, 3 );
function filter_show_variation_price( $condition, $product, $variation ){
    if( $variation->get_price() === "" ) return false;
    else return true;
}

Percentage increase in price based on latest transaction date and previous transaction date


Tag : sql , By : Hunter
Date : March 29 2020, 07:55 AM
this one helps. , , This might be overly complicated.
Set up some random data:
IF OBJECT_ID('tempdb..#Cities') IS NOT NULL
BEGIN
    DROP TABLE #Cities;
END;

CREATE TABLE #Cities
(
    Country VARCHAR(20)
   , City    VARCHAR(20)
);

IF OBJECT_ID('tempdb..#Data') IS NOT NULL
BEGIN
    DROP TABLE #Data;
END;

CREATE TABLE #Data
(
    Country VARCHAR(20)
   , City    VARCHAR(20)
   , Price   DECIMAL(13, 4)
   , Date    DATETIME
);

INSERT INTO #Cities
VALUES      ('Country 1', 'City 1'), ('Country 1', 'City 2'), ('Country 1', 'City 3'), ('Country 2', 'City 4'), ('Country 2', 'City 5');


INSERT INTO #Data
SELECT Country
    , City
    , ROUND(RAND(CHECKSUM(NEWID())) * 100, 4) AS Price
    , DATEADD(DAY, ROUND(RAND(CHECKSUM(NEWID())) * 10, 0), GETDATE()) AS Date
FROM     #Cities
UNION
SELECT Country
    , City
    , ROUND(RAND(CHECKSUM(NEWID())) * 100, 4)
    , DATEADD(DAY, ROUND(RAND(CHECKSUM(NEWID())) * 10, 0), GETDATE())
FROM     #Cities;

--Delete duplicate dates

WITH data3 AS
(
SELECT *,ROW_NUMBER() OVER (PARTITION BY Country,City,Date ORDER BY Country,City,Date) AS RN
FROM #Data
)
DELETE FROM data3 WHERE RN<>1
SELECT        Dates.*
          , Latest.Price AS Latestprice
          , Previous.Price AS Previousprice
          , ((Latest.Price - Previous.Price) / Previous.Price) * 100 AS Percentageincrease
FROM
(
    SELECT    C.*
          , Latestdate.Latestdate
          , Previousdate.Previousdate
    FROM      #Cities AS C
            LEFT JOIN
    (
       --Latest Date for each county, city
       SELECT Country
           , City
           , MAX(Date) AS Latestdate
       FROM   #Data
       GROUP BY Country
            , City
    ) AS Latestdate ON Latestdate.Country = C.Country
                   AND Latestdate.City = C.City
            LEFT JOIN
    (
       --Previous Date for each county, city
       SELECT Country
           , City
           , Date AS Previousdate
       FROM
       (
          SELECT Country
              , City
              , Date
              , RANK() OVER(PARTITION BY Country
                                  , City ORDER BY Date DESC) AS Rank
          FROM   #Data
       ) AS A
       WHERE  Rank = 2
    ) AS Previousdate ON Previousdate.Country = C.Country
                    AND Previousdate.City = C.City
) AS Dates
JOIN #Data AS Latest ON Latest.Country = Dates.Country
                    AND Latest.City = Dates.City
                    AND Latest.Date = Dates.Latestdate
JOIN #Data AS Previous ON Previous.Country = Dates.Country
                     AND Previous.City = Dates.City
                     AND Previous.Date = Dates.Previousdate
SELECT D.Country
    , D.City
    , D.Date
    , Lag(Date) OVER(PARTITION BY Country
                           , City ORDER BY Date) AS Previousdate
    , D.Price
    , Lag(Price) OVER(PARTITION BY Country
                            , City ORDER BY Date) AS Previousprice
    , 100 * (Price / Lag(Price) OVER(PARTITION BY Country
                                        , City ORDER BY Date) - 1) AS PercentageIncrease
FROM   #Data AS D;
SELECT *
FROM
(
    SELECT D.Country
        , D.City
        , D.Date
        , Lag(Date) OVER(PARTITION BY Country
                              , City ORDER BY Date) AS Previousdate
        , D.Price
        , Lag(Price) OVER(PARTITION BY Country
                               , City ORDER BY Date) AS Previousprice
        , 100 * (Price / Lag(Price) OVER(PARTITION BY Country
                                           , City ORDER BY Date) - 1) AS Percentageincrease
        , ROW_NUMBER() OVER(PARTITION BY Country
                                , City ORDER BY Date DESC) AS Rn
    FROM   #Data AS D
) AS A
WHERE  Rn = 1
ORDER BY Country
      , City;
Related Posts Related QUESTIONS :
  • SQL Query Select from 1 table and return data based on 2 columns
  • how to use rank/join and where together
  • How to create new column with values counting up every 9th value with SQL?
  • Most frequent combination of words/characters SQL Server
  • Why can't I access a field defined as "Select 1" from a subquery in the outer query?
  • How to solve Msg 8115, Level 16, State 2, Line 2 Arithmetic overflow error converting expression to data type int.?
  • UPDATE row inserted earlier in CTE
  • Display current month values based upon abbreviation (Oct) SQL Server
  • SQL Modify returned select value without union
  • How to put a variable in a like statement in vba?
  • More Elegant way to Batch Validate Phone Numbers
  • SQL find parent where children match over multiple rows
  • A combo box that has to be filter the same data in that field
  • Exclude updated record from trigger function
  • Insert into table from select only when select returns valid rows
  • How to fix SQLite3::SQLException: near "to": syntax error: SELECT "".* FROM "" WHERE "
  • Filter msdb.dbo.sysjobsteps.command into seperate columns
  • How to extract year or month,day from oracle function without using sub-query?
  • Reset sum when condition is met in Oracle
  • Date Between (Start & Now)
  • Reset running sum when condition is met in Oracle
  • Why is my date criteria filtering incorrectly in a MsysObjects query using DCount?
  • Stripping date/time delimiters in an SSIS csv export
  • SSIS Error on insertion - Error when new primary keys in Dimension table
  • How can I make a temp table of specific datetime data within a range?
  • AnalysisException: Syntax error in SQL After multiple join
  • SQL Query Multiple Columns Using Distinct on One Column Only and Using Order By
  • Sum inventory item groups
  • TSQL: Parsing strings with various characters
  • Using SQL Server : how to use select criteria based on sum
  • Inserting dynamic pivot Result into Temp table
  • Joining multiple fields in a dataset joined with descriptions
  • Conditional WHERE EXISTS in Oracle query
  • How to get the count of each unique value in a column between two dates?
  • SQL: Select only if multiple values are IN 1 column from CatalogTable
  • In a query (no editing of tables) how do I join data without any similarities?
  • Create nested json blobs in PostgreSQL
  • Getting extra dates while using cte
  • Way to alter one table if another was altered
  • Proper use of semicolons in functions and procedures
  • Cursor Not looping all the Records
  • Select inner join returns wrong result
  • Group By showing duplicates
  • Error in using subquery in access join query
  • How do I use a composite pk in a stored procedure?
  • Oracle Unique Indexes
  • Spooling data to CSV truncates
  • How do views reduce code duplication?
  • SQL: Gather right hand values from a join
  • SQL Agent Logon - What is going on?
  • How do I combine two rows of same part, but add quantities?
  • How to optimize this SQL query for a rectangular region?
  • Pass data from ssrs subreport to parent
  • how to enter values in rowguid column?
  • Read multiple tables from dataset in Powershell
  • In SQL how to I exclude a record if there are more than 3 characters after a dash
  • What is the difference between check and foreign key?
  • How to return a record from function, executed by INSERT/UPDATE rule (trigger)?
  • SQL order by oldest from Unix Timestamps
  • How to convert decode function in oracle to standard big query
  • shadow
    Privacy Policy - Terms - Contact Us © scrbit.com