Quantcast
Channel: Mockaroo Community Forum - Latest posts
Viewing all 2665 articles
Browse latest View live

Convert a datatype error

$
0
0

Looks like the formula you want is:

line_price.to_i * line_quant.to_i

Creating an email address with a sequential number?

$
0
0

Hi,

I need to create a set of email address that looks like the following

michael.thomas+userid1@mydomain.com
michael.thomas+userid2@mydomain.com
..

michael.thomas+userid1000@mydomain.com

As you can see here the number is increasing by a value of 1?

Is this possible?
Thanks
MIk

Creating an email address with a sequential number?

Auto Increment Key fields

$
0
0

Auto Increment Key fields
Can we add auto increment fields similar to SQL server
Starting at 1 and going up by 1 for each record ?

Jawahar

Auto Increment Key fields

$
0
0

Row Number automatically does this, or you can use Sequence to start at a specific value.

Random date in YYYYMMDD

$
0
0

The supported date formats do not include the old school YYYYMMDD format.

Turns out you can do this in ruby in the formula editor:

(now() - days(random(0,5000))).strftime('%Y%m%d')

This will give you ~15 years of random dates.

Using SQL Expression

$
0
0

As possible solution for your first query (Select sum(pd_subtotal) FROM PurchaseOrder_Detail where pd_po_nbr=:ph_po_nbr), I'd probably use something like:

select 
  pd_vendor_nbr,
  sum(pd_qty) as "sum of subtotals"
from PurchaseOrder_Detail
group by pd_vendor_nbr
order by pd_vendor_nbr

Your second query runs into difficulties, because you are SELECTing a column that does not exist (in the PurchaseOrder_Detail table).

If you want to write a SQL statement that calculates the sum of subtotals of the "Details" table, and stores it in the ph_amount_totals column of the "Header" table, you could use:

update PurchaseOrder_Header
set ph_amount_total = ( 
    select 
      sum(pd_qty)
    from PurchaseOrder_Detail
    where ph_vendor_nbr = pd_vendor_nbr
    group by pd_vendor_nbr 
   )

-- Tested on an Oracle 12c server.

You could probably get away with NOT having the ph_amount_total column (in the "Header" table) and the pd_subtotal column (in the "Details") table, as the values stored in these columns are "calculated" ie they can be generated on the fly.

Also, I'm not quite sure why you have used the operator := in the WHERE clause of your queries (did you want to use bind variables?).

Generating Real UK Postcodes

$
0
0

Hi
Here's a possible solution for you (it's maybe "overkill", but quite flexible - if you ever need any other postcodes), using some database programming.
I have used M1-M18, then 1 digit (0-9), then 2 letters.
I'm not quite sure which "double" letter combinations are valid (at the end of the postcode), so my query generates all 676 possibilities (AA-ZZ).
I got 121680 combinations by doing this. You can get an evenly distributed sample by using the last query.

I know that it would be a tall order to understand and run the code if you are new to databases - but maybe this type of coding is not a problem for you :slight_smile: Cheers
Stefan

-- ----------------------------------------------------------------------------
-- create and populate 3 small tables
-- ----------------------------------------------------------------------------
-- pc1: hold the first (couple of) letter(s)
create table pc1 (
  prefix varchar2(5) unique
);

-- pc2: hold all possible digits
create table pc2 (
  digit varchar2(1) unique
);

-- pc3: hold all possible letters
create table pc3 (
  postfix varchar2(1) unique
);

-- populate the tables
begin
  for pre in 1 .. 18
  loop
    insert into pc1 values ( 'M' || pre );
  end loop; 
  for digit in 0 .. 9
  loop
    insert into pc2 values (digit);
  end loop;
  for i in 1 .. 26
  loop
    insert into pc3 values ( chr(i + 64) );
  end loop;
end;

-- ----------------------------------------------------------------------------
-- SELECT all possible postcodes
-- ----------------------------------------------------------------------------

select prefix || ' ' || digit || letters postcode
from pc1, 
     pc2, 
     ( select L1.postfix || L2.postfix letters
       from pc3 L1, pc3 L2 )


-- postcode count
select count(*)
from pc1, 
     pc2, 
     ( select L1.postfix || L2.postfix letters
       from pc3 L1, pc3 L2 )

--> 121680

-- ----------------------------------------------------------------------------
--   use a sequence for numbering the postcodes, and store them in a table
-- ----------------------------------------------------------------------------

create sequence pc_seq
start with 1
increment by 1

create table postcodes
as 
select pc_seq.NEXTVAL id, prefix || ' ' || digit || letters postcode
from pc1, 
     pc2, 
     ( select L1.postfix || L2.postfix letters
       from pc3 L1, pc3 L2 )

-- ----------------------------------------------------------------------------
-- select how ever many postcodes you need 
-- (change the number in the mod() function call)
-- ----------------------------------------------------------------------------
select * from postcodes
where mod(id, 1000) = 0

Generate data with datetime between two precised hours

$
0
0

Would it be possible to have datetime increment between two precised hours :

Here is what I have for my datetime :

(date('28/04/2017') + 26400 + minutes(id)).strftime('%d-%m-%Y %H:%M:%S')

It starts at 07:27:00 and increments every minute, but I want it to stop at 19:00:00 and restart at 07:27:00 and so on.

Generate data with datetime between two precised hours

$
0
0

Yes, you can use a sequence with the "restart at" option to generate the number of minutes. Then use a formula to add that to a fixed date.

Generate data with datetime between two precised hours

JSON Array without child Dictionary

$
0
0

I'm trying to replicate the following data structure but can't figure out a way to achieve this, any help would be much appreciated:

"payload": {
"id": "1",
"modalStack": [],
"pageStack": [
"page1",
"page2"
]
}
or
"payload": {
"id": "1",
"modalStack": [
"modal1",
"modal2"
]
"pageStack": [],
}

Obviously checked out JSON Array type, but I don't see how to just have a list of elements in the array. Rather than have an array of dictionaries.

JSON Array without child Dictionary

$
0
0

You can get an array of strings by simply giving any field a name with brackets. For example: modalStack[1-3] will generate an array with between 1 and 3 items inclusive. You'll probably want to use custom list for the field type.

Relationship or conditions in dataset

$
0
0

Hello everybody,
maybe my question has been answered already, but I'm no native English speaking person and for that reason it's quite difficult to use the correct searching tags.
I want to simulate that children from the social upper class, will be forced to visit high school by their parents whereas lower class parents are not interested in a "school career". Calculating the dataset in SPSS should show correlation between this to items.

Is it possible to create a dataset under such conditions in Mockaroo?

Kind regards,
Guenter

Relationship or conditions in dataset


Relationship or conditions in dataset

$
0
0

Hello Mark,
thank you for your example but this formula looks to strict for me.
I have a scale for social layer with lower, middle and upper class. If I would use this kind of formula, it would mean that all parents of lower class children wouldn't be interested in sending them into high school. That wouldn't be realistic. In your example there would be a correlation size of 1 between

I think it would be necessary to define which amount of correlation of two items should be generated inside the sample data.

Regards,
Guenter

Use sha256 function on another field

$
0
0

How can i use sh256 function on another field ?

Ex:

Name -> Buzzword
Crypt - > sha256('Name')

Regex with referenced fields

$
0
0

I created a field called "industry" with different industry values.

I wanted to create another field called "preferred industry" with 3 industries, separated by commas.
e.g.
Retail, FMCG, Hospitality

To do this put this regex in "preferred industry":
({{industry}},{{industry}},{{industry}})

However it gives a result like this:
FMCG,{{industry}},{{industry}}

Am I using the right method to generate a list of x values, separated by commas?

Thank you!

Ivan

Regex with referenced fields

$
0
0

Here is an example that uses bracket notation to generate multiple values (for example, preferred_industry[1-3] will generate between 1 and 3 values in an array). It also uses an inline formula (the f(x) button) to convert the array to a comma-delimited list using Ruby's join function.

http://mockaroo.com/12e17bd0

Use sha256 function on another field

Viewing all 2665 articles
Browse latest View live